rubygb 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/Gemfile.lock +13 -1
  4. data/README.md +3 -3
  5. data/lib/galp/memory.inc +153 -0
  6. data/lib/rgbds/LICENSE +32 -0
  7. data/lib/rubygb/cli.rb +26 -2
  8. data/lib/rubygb/template/template.rb +99 -0
  9. data/lib/rubygb/version.rb +1 -1
  10. data/lib/rubygb.rb +1 -0
  11. data/rubygb.gemspec +2 -0
  12. data/scrap/example/gbhw.inc +645 -0
  13. data/{lib/galp/EXAMPLE1.TXT → scrap/example/hello-world-with-comments.asm} +123 -113
  14. data/scrap/example/hello-world-with-comments.gb +0 -0
  15. data/scrap/example/hello-world-with-comments.map +65 -0
  16. data/scrap/example/hello-world-with-comments.obj +0 -0
  17. data/scrap/example/hello-world-with-comments.sym +12 -0
  18. data/scrap/example/ibmpc1.inc +2400 -0
  19. data/scrap/test/lib/gbhw.inc +645 -0
  20. data/scrap/test/lib/ibmpx1.inc +2400 -0
  21. data/scrap/test/lib/memory.inc +153 -0
  22. data/scrap/test/test.gb +0 -0
  23. data/scrap/test/test.map +65 -0
  24. data/scrap/test/test.obj +0 -0
  25. data/scrap/test/test.s +91 -0
  26. data/scrap/test/test.sym +12 -0
  27. metadata +37 -31
  28. data/lib/galp/AND.GIF +0 -0
  29. data/lib/galp/ARROW.GIF +0 -0
  30. data/lib/galp/C.BAT +0 -5
  31. data/lib/galp/CHANGES.TXT +0 -5
  32. data/lib/galp/EXAMPLE.LNK +0 -7
  33. data/lib/galp/GBSPEC.TXT +0 -1761
  34. data/lib/galp/INDEX.HTM +0 -23
  35. data/lib/galp/INSTR.HTM +0 -563
  36. data/lib/galp/MEM1.HTM +0 -199
  37. data/lib/galp/OPCODES.HTM +0 -351
  38. data/lib/galp/OR.GIF +0 -0
  39. data/lib/galp/README.TXT +0 -4
  40. data/lib/galp/REGS.HTM +0 -77
  41. data/lib/galp/RL.GIF +0 -0
  42. data/lib/galp/RLC.GIF +0 -0
  43. data/lib/galp/RR.GIF +0 -0
  44. data/lib/galp/RRC.GIF +0 -0
  45. data/lib/galp/SETUP.BAT +0 -7
  46. data/lib/galp/SLA.GIF +0 -0
  47. data/lib/galp/SRA.GIF +0 -0
  48. data/lib/galp/SRL.GIF +0 -0
  49. data/lib/galp/START.HTM +0 -24
  50. data/lib/galp/SWAP.GIF +0 -0
  51. data/lib/galp/VID1.HTM +0 -34
  52. data/lib/galp/XOR.GIF +0 -0
  53. /data/lib/galp/{GBHW.TXT → gbhw.inc} +0 -0
  54. /data/lib/galp/{IBMPC1.TXT → ibmpx1.inc} +0 -0
  55. /data/{lib/galp/MEMORY.TXT → scrap/example/memory.asm} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3dd7fa09adc216340304dd6680d2081184b570a1
4
- data.tar.gz: 8f99e04afc723055a64f76450a6901f27a757fb8
3
+ metadata.gz: a877dc8d5031406712a6a929162ba7628435134b
4
+ data.tar.gz: 2fb36c1a69f7b6ee63879a957865945ab733faec
5
5
  SHA512:
6
- metadata.gz: ac40dd65075a0ba6d53b7b4f674e7544caeab46e81cdc4623f12e7387c1866128cc1df2faf8da355b226e95afa3dfe1664a720654e80e682595e01249b68c7fe
7
- data.tar.gz: 5191b4f9e58316e51c7b08a29c0691b96a0558e231fbe98c74bde35f6ad0e5861d0667f12f57e3b27003e9d3906fb5b6548860cb1f3a239739b1ffdcf77f21a5
6
+ metadata.gz: 5c7facde8265ed86e9d18a1de766c1bc27019a3eb06435a791b935fa232925c2ed720dbe64f18c3c8b7f0e78b943793990f24f625a468489c2c793c5310489c8
7
+ data.tar.gz: d6dee2a3b3dc6ed2666337d87d1c6059a8ccf4e9f29413f7db9de11929bb300780b1e95d040b46ac095f1e52d051d9f16875897399c743d619b3e8311b8c66ed
data/.DS_Store CHANGED
Binary file
data/Gemfile.lock CHANGED
@@ -1,14 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubygb (0.1.0)
4
+ rubygb (0.2.0)
5
5
  thor (~> 0.19)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ byebug (8.2.2)
11
+ coderay (1.1.1)
12
+ method_source (0.8.2)
10
13
  minitest (5.8.4)
14
+ pry (0.10.3)
15
+ coderay (~> 1.1.0)
16
+ method_source (~> 0.8.1)
17
+ slop (~> 3.4)
18
+ pry-byebug (3.3.0)
19
+ byebug (~> 8.0)
20
+ pry (~> 0.10)
11
21
  rake (10.5.0)
22
+ slop (3.6.0)
12
23
  thor (0.19.1)
13
24
 
14
25
  PLATFORMS
@@ -16,6 +27,7 @@ PLATFORMS
16
27
 
17
28
  DEPENDENCIES
18
29
  minitest
30
+ pry-byebug
19
31
  rake
20
32
  rubygb!
21
33
 
data/README.md CHANGED
@@ -5,16 +5,16 @@ Bundles the [rgbds-linux](https://github.com/bentley/rgbds) compiler (for OSX) a
5
5
 
6
6
  ## Setup
7
7
 
8
- Add to your `Gemfile`:
8
+ Install from rubygems
9
9
 
10
10
  ```ruby
11
- gem 'rubygb'
11
+ gem install rubygb
12
12
  ```
13
13
 
14
-
15
14
  ## Usage
16
15
 
17
16
  ```ruby
17
+ rubygb build FILENAME
18
18
  ```
19
19
 
20
20
  ## Awesomeness
@@ -0,0 +1,153 @@
1
+
2
+ ;*
3
+ ;* MEMORY.ASM - Memory Manipulation Code
4
+ ;* by GABY. Inspired by Carsten Sorensen & others.
5
+ ;*
6
+ ;* V1.0 - Original release
7
+ ;*
8
+
9
+ ;If all of these are already defined, don't do it again.
10
+
11
+ IF !DEF(MEMORY1_ASM)
12
+ MEMORY1_ASM SET 1
13
+
14
+
15
+
16
+ ; Macro that pauses until VRAM available.
17
+
18
+ lcd_WaitVRAM: MACRO
19
+ ld a,[rSTAT] ; <---+
20
+ and STATF_BUSY ; |
21
+ jr nz,@-4 ; ----+
22
+ ENDM
23
+
24
+ PUSHS ; Push the current section onto assember stack.
25
+
26
+ SECTION "Memory1 Code",HOME
27
+
28
+ ;***************************************************************************
29
+ ;*
30
+ ;* mem_Set - "Set" a memory region
31
+ ;*
32
+ ;* input:
33
+ ;* a - value
34
+ ;* hl - pMem
35
+ ;* bc - bytecount
36
+ ;*
37
+ ;***************************************************************************
38
+ mem_Set::
39
+ inc b
40
+ inc c
41
+ jr .skip
42
+ .loop ld [hl+],a
43
+ .skip dec c
44
+ jr nz,.loop
45
+ dec b
46
+ jr nz,.loop
47
+ ret
48
+
49
+ ;***************************************************************************
50
+ ;*
51
+ ;* mem_Copy - "Copy" a memory region
52
+ ;*
53
+ ;* input:
54
+ ;* hl - pSource
55
+ ;* de - pDest
56
+ ;* bc - bytecount
57
+ ;*
58
+ ;***************************************************************************
59
+ mem_Copy::
60
+ inc b
61
+ inc c
62
+ jr .skip
63
+ .loop ld a,[hl+]
64
+ ld [de],a
65
+ inc de
66
+ .skip dec c
67
+ jr nz,.loop
68
+ dec b
69
+ jr nz,.loop
70
+ ret
71
+
72
+ ;***************************************************************************
73
+ ;*
74
+ ;* mem_Copy - "Copy" a monochrome font from ROM to RAM
75
+ ;*
76
+ ;* input:
77
+ ;* hl - pSource
78
+ ;* de - pDest
79
+ ;* bc - bytecount of Source
80
+ ;*
81
+ ;***************************************************************************
82
+ mem_CopyMono::
83
+ inc b
84
+ inc c
85
+ jr .skip
86
+ .loop ld a,[hl+]
87
+ ld [de],a
88
+ inc de
89
+ ld [de],a
90
+ inc de
91
+ .skip dec c
92
+ jr nz,.loop
93
+ dec b
94
+ jr nz,.loop
95
+ ret
96
+
97
+
98
+ ;***************************************************************************
99
+ ;*
100
+ ;* mem_SetVRAM - "Set" a memory region in VRAM
101
+ ;*
102
+ ;* input:
103
+ ;* a - value
104
+ ;* hl - pMem
105
+ ;* bc - bytecount
106
+ ;*
107
+ ;***************************************************************************
108
+ mem_SetVRAM::
109
+ inc b
110
+ inc c
111
+ jr .skip
112
+ .loop push af
113
+ di
114
+ lcd_WaitVRAM
115
+ pop af
116
+ ld [hl+],a
117
+ ei
118
+ .skip dec c
119
+ jr nz,.loop
120
+ dec b
121
+ jr nz,.loop
122
+ ret
123
+
124
+ ;***************************************************************************
125
+ ;*
126
+ ;* mem_CopyVRAM - "Copy" a memory region to or from VRAM
127
+ ;*
128
+ ;* input:
129
+ ;* hl - pSource
130
+ ;* de - pDest
131
+ ;* bc - bytecount
132
+ ;*
133
+ ;***************************************************************************
134
+ mem_CopyVRAM::
135
+ inc b
136
+ inc c
137
+ jr .skip
138
+ .loop di
139
+ lcd_WaitVRAM
140
+ ld a,[hl+]
141
+ ld [de],a
142
+ ei
143
+ inc de
144
+ .skip dec c
145
+ jr nz,.loop
146
+ dec b
147
+ jr nz,.loop
148
+ ret
149
+
150
+ POPS ; Pop the current section off of assember stack.
151
+
152
+ ENDC ;MEMORY1_ASM
153
+
data/lib/rgbds/LICENSE ADDED
@@ -0,0 +1,32 @@
1
+ rgbasm and rgblink are derived from Justin Lloyd's RGBDS, which is
2
+ released under the following license:
3
+
4
+ DO WHATEVER PUBLIC LICENSE*
5
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
6
+
7
+ 0. You can do whatever you want to with the work.
8
+ 1. You cannot stop anybody from doing whatever they want to with the work.
9
+ 2. You cannot revoke anybody elses DO WHATEVER PUBLIC LICENSE in the work.
10
+
11
+ This program is free software. It comes without any warranty, to
12
+ the extent permitted by applicable law. You can redistribute it
13
+ and/or modify it under the terms of the DO WHATEVER PUBLIC LICENSE
14
+
15
+ Software originally created by Justin Lloyd @ http://otakunozoku.com/
16
+
17
+
18
+ rgbfix was rewritten from scratch by Anthony J. Bentley, and is released
19
+ under the ISC license; see the source file for the text of the license.
20
+
21
+ The UTF-8 decoder in src/asm/charmap.c was written by Björn Höhrmann and is
22
+ released under the MIT license. The remainder of charmap.c was written by
23
+ stag019, and is released under the ISC license.
24
+
25
+ extern/err.c is derived from the Musl C library, http://www.musl-libc.org,
26
+ and is released under the MIT license.
27
+
28
+ extern/reallocarray.c is derived from the OpenBSD Project,
29
+ http://www.openbsd.org, and is released under the ISC license.
30
+
31
+ extern/strl.c is derived from the OpenBSD Project, http://www.openbsd.org,
32
+ and is released under the BSD license.
data/lib/rubygb/cli.rb CHANGED
@@ -1,11 +1,35 @@
1
1
  require 'thor'
2
-
2
+ require 'fileutils'
3
+ require 'pry-byebug'
3
4
  module Rubygb
4
5
  class CLI < Thor
5
- desc 'build FILENAME', 'attempt to assemble, link and fix FILENAME and create a gb rom from it'
6
+ desc 'build FILENAME', 'attempt to assemble, link + fix FILENAME and create a gb rom from it'
6
7
  option :no_fix, :type => :boolean
7
8
  def build filename
8
9
  Rubygb.build filename, options
9
10
  end
11
+
12
+ desc 'init PROJECT_NAME', 'create a new gameboy project at the location'
13
+ def init project_name
14
+ puts "Creating new project at #{File.expand_path project_name}"
15
+ raise "Project already exists at #{File.expand_path project_name}!"if Dir.exists? project_name
16
+
17
+ Dir.mkdir project_name
18
+ galp_dest = File.join(project_name,"lib")
19
+ Dir.mkdir galp_dest
20
+ galp_lib = File.expand_path(File.join(File.dirname(__FILE__),"..","galp"))
21
+
22
+ Dir.glob(File.join(galp_lib,"*")) do |file|
23
+ puts "Copying #{File.basename(file)}..."
24
+ FileUtils.copy file, galp_dest
25
+ end
26
+
27
+ template = Template.basic(project_name)
28
+ filename = File.join(project_name,"#{project_name}.s")
29
+ puts "Generating #{filename}..."
30
+ File.open(filename,"w") {|f| f << template}
31
+
32
+ puts "Done!"
33
+ end
10
34
  end
11
35
  end
@@ -0,0 +1,99 @@
1
+ module Rubygb
2
+ class Template
3
+
4
+ def self.basic name
5
+ %(; #{name}.s
6
+ ;
7
+ ; TODO: summary
8
+
9
+ INCLUDE "lib/gbhw.inc" ; gameboy hardware definitions
10
+ INCLUDE "lib/ibmpx1.inc" ; ibm ascii font macros
11
+
12
+
13
+ ; interrupts
14
+ SECTION "Vblank",HOME[$0040]
15
+ reti
16
+ SECTION "LCDC",HOME[$0048]
17
+ reti
18
+ SECTION "Timer_Overflow",HOME[$0050]
19
+ reti
20
+ SECTION "Serial",HOME[$0058]
21
+ reti
22
+ SECTION "p1thru4",HOME[$0060]
23
+ reti
24
+
25
+ ; jump to start of user code at `begin`
26
+
27
+ SECTION "start",HOME[$0100]
28
+ nop
29
+ jp begin
30
+
31
+ ; rom header - no memory bank controller, 32k rom, 0; ram
32
+ ROM_HEADER ROM_NOMBC, ROM_SIZE_32KBYTE, RAM_SIZE_0KBYTE
33
+
34
+
35
+ INCLUDE "lib/memory.inc"; memory copying macros
36
+
37
+ TileData:
38
+ chr_IBMPC1 1,8 ; LOAD ENTIRE CHARACTER SET
39
+
40
+ ; initialization
41
+ begin:
42
+ nop
43
+ di
44
+ ld sp, $ffff ; set the stack pointer to highest mem location + 1
45
+ init:
46
+ ld a, %11100100 ; Window palette colors, from darkest to lightest
47
+ ld [rBGP], a ; CLEAR THE SCREEN
48
+
49
+ ld a,0 ; SET SCREEN TO TO UPPER RIGHT HAND CORNER
50
+ ld [rSCX], a
51
+ ld [rSCY], a
52
+ call StopLCD ; YOU CAN NOT LOAD $8000 WITH LCD ON
53
+ ld hl, TileData
54
+ ld de, _VRAM ; $8000
55
+ ld bc, 8*256 ; the ASCII character set: 256 characters, each with 8 bytes of display data
56
+ call mem_CopyMono ; load tile data
57
+ ld a, LCDCF_ON|LCDCF_BG8000|LCDCF_BG9800|LCDCF_BGON|LCDCF_OBJ16|LCDCF_OBJOFF
58
+ ld [rLCDC], a
59
+ ld a, 32 ; ASCII FOR BLANK SPACE
60
+ ld hl, _SCRN0
61
+ ld bc, SCRN_VX_B * SCRN_VY_B
62
+ call mem_SetVRAM
63
+
64
+ ; main
65
+ ld hl,Title
66
+ ld de, _SCRN0+3+(SCRN_VY_B*7) ;
67
+ ld bc, TitleEnd-Title
68
+ call mem_CopyVRAM
69
+
70
+ wait:
71
+ halt
72
+ nop
73
+ jr wait
74
+
75
+ Title:
76
+ DB "#{name} + rubygb!"
77
+ TitleEnd:
78
+
79
+ StopLCD:
80
+ ld a,[rLCDC]
81
+ rlca
82
+ ret nc
83
+
84
+ .wait:
85
+ ld a,[rLY]
86
+ cp 145
87
+ jr nz,.wait
88
+
89
+
90
+ ld a,[rLCDC]
91
+ res 7,a
92
+ ld [rLCDC],a
93
+
94
+ ret
95
+ )
96
+
97
+ end
98
+ end
99
+ end
@@ -1,4 +1,4 @@
1
1
  module Rubygb
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
4
4
 
data/lib/rubygb.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative "rubygb/version"
2
2
  require_relative "rubygb/rubygb"
3
3
  require_relative "rubygb/cli"
4
+ require_relative "rubygb/template/template"
4
5
 
5
6
  module Rubygb
6
7
  end
data/rubygb.gemspec CHANGED
@@ -19,5 +19,7 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.required_ruby_version = "~> 2.0"
21
21
  gem.add_development_dependency "rake"
22
+ gem.add_development_dependency "pry-byebug"
23
+
22
24
  gem.add_runtime_dependency "thor", "~> 0.19"
23
25
  end