diff options
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | enemiesattacks/basic.gbasm | 16 | ||||
-rw-r--r-- | enemiesattacks/freeze.gbasm | 16 | ||||
-rw-r--r-- | enemiesattacks/laser.gbasm | 16 | ||||
-rw-r--r-- | entity/list.gbasm | 2 | ||||
-rw-r--r-- | init.gbasm | 24 | ||||
-rw-r--r-- | scripts/set_checksums.py | 24 |
7 files changed, 99 insertions, 7 deletions
@@ -8,7 +8,11 @@ tileset.gbasm: ./scripts/generate-tiledata.py $(wildcard ./sprites/**/* ./sprite %.gbasm: ./%.gbtxt ./scripts/generate_from_gbtxt.py python ./scripts/generate_from_gbtxt.py $< > $@ -build/main.rom: main.gbasm tileset.gbasm text.gbasm dialogues/text.gbasm +build/main.rom: build/main.rom.unsigned + cp build/main.rom.unsigned build/main.rom + python scripts/set_checksums.py build/main.rom + +build/main.rom.unsigned: main.gbasm tileset.gbasm text.gbasm dialogues/text.gbasm mkdir -p build gbasm $< $@ > build/main.sym @@ -23,4 +27,4 @@ gearboy: build/main.rom gearboy build/main.rom build/main.sym clean: - rm -rf build + rm -rf buil1 diff --git a/enemiesattacks/basic.gbasm b/enemiesattacks/basic.gbasm index c617b7a..63bf3e4 100644 --- a/enemiesattacks/basic.gbasm +++ b/enemiesattacks/basic.gbasm @@ -1,5 +1,21 @@ Basic_Enemy_Attack: ; Direction to face in E. Result in BC (XY), Direction in D LD A, E + DEC A + DEC D + XOR D + INC D + CP $00 + JR Z, =.attack + BIT 1, A + JR NZ, =.attack + + LD A, E + OR $00 + LD D, A + RET + + .attack: + LD A, E OR $10 LD D, A diff --git a/enemiesattacks/freeze.gbasm b/enemiesattacks/freeze.gbasm index eb27a48..35dadf3 100644 --- a/enemiesattacks/freeze.gbasm +++ b/enemiesattacks/freeze.gbasm @@ -1,5 +1,21 @@ Freeze_Enemy_Attack: ; Direction to face in E. Result in BC (XY), Direction in D LD A, E + DEC A + DEC D + XOR D + INC D + CP $00 + JR Z, =.attack + BIT 1, A + JR NZ, =.attack + + LD A, E + OR $00 + LD D, A + RET + + .attack: + LD A, E OR $10 LD D, A diff --git a/enemiesattacks/laser.gbasm b/enemiesattacks/laser.gbasm index caf6db2..c26e4e3 100644 --- a/enemiesattacks/laser.gbasm +++ b/enemiesattacks/laser.gbasm @@ -1,4 +1,20 @@ Laser_sight_check: ; BC = XY of the enemy. D is unchanged. Direction to face in E (or 0 if not) + LD A, E + DEC A + DEC D + XOR D + INC D + CP $00 + JR Z, =.attack + BIT 1, A + JR NZ, =.attack + + LD A, E + OR $00 + LD D, A + RET + + .attack: LD E, $00 ; straight line + distance <= 4 diff --git a/entity/list.gbasm b/entity/list.gbasm index ff70248..f142505 100644 --- a/entity/list.gbasm +++ b/entity/list.gbasm @@ -151,7 +151,7 @@ Entity_list: .DB $05 ; Interaction Jump Table index - .DB $01 + .DB $02 ; Starting health .DB $00 @@ -13,15 +13,31 @@ Start: JP =Initialize_RAM .PADTO 0x0104 -Nintendo_Logo: ; The Nintendo logo must be stored in bytes 0x104-133 +Header: +.Nintendo_Logo: ; The Nintendo logo must be stored in bytes 0x104-133 .DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D .DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99 .DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E .PADTO 0x0134 -Checksum: ; The bytes 0x134-0x14d need to add up to 0xe7 (= 0xff - 0x19) - .DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 - .DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$e7 + +.Title: +.PADTO 0x13f + +.Manufacturer_code: +.PADTO 0x142 + +.CGB_Flag: .DB $69 +.Licensee_code_new: .DB $00, $00 +.SGB_Flag: .DB $00 +.MBC: .DB $01 +.ROM_size: .DB $00 +.RAM_size: .DB $00 ; The .sav cartridge kind of ram +.Destination_code: .DB $01 ; Overseas +.Licensee_code_old: .DB $00 +.Version_number: .DB $42 +.Header_checksum: .DB $00 ; Will be set after assembly by build scripts +.Global_checksum: .DB $00, $00 ; Will be set after assembly by build scripts Initialize_RAM: ; Disable Interrupts diff --git a/scripts/set_checksums.py b/scripts/set_checksums.py new file mode 100644 index 0000000..e05d1cf --- /dev/null +++ b/scripts/set_checksums.py @@ -0,0 +1,24 @@ +import sys + +if len(sys.argv) != 2: + raise ValueError("Rom file must be specified as first argument") + +rom_filename = sys.argv[1] + +rom_file = open(rom_filename, 'r+b') + +rom_file.seek(0x0134) + +header = rom_file.read(0x19) + +header_checksum = 0 +for b in header: + header_checksum = (header_checksum - int(b) - 1) & 0xff + +print("HEADER CHECKSUM =", hex(header_checksum), file=sys.stderr) + +rom_file.seek(0x014d) + +rom_file.write(bytes(bytearray([header_checksum]))) + +rom_file.close() |