diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | definitions.gbasm | 5 | ||||
-rw-r--r-- | dialogues/demo_quest.gbasm | 1 | ||||
-rw-r--r-- | enemiesattacks/laser.gbasm | 32 | ||||
-rw-r--r-- | entity/list.gbasm | 2 | ||||
-rw-r--r-- | main.gbasm | 3 | ||||
-rw-r--r-- | map/dungeons.gbasm | 59 | ||||
-rw-r--r-- | map/objects.gbasm | 4 | ||||
-rw-r--r-- | modes/dungeongeneration.gbasm | 24 | ||||
-rw-r--r-- | utils.gbasm | 1 |
10 files changed, 95 insertions, 40 deletions
@@ -1,6 +1,6 @@ all: run -.PHONY: build/main.rom clean +.PHONY: build/main.rom.unsigned build/main.rom clean tileset.gbasm: ./scripts/generate-tiledata.py $(wildcard ./sprites/**/* ./sprites/*) python ./scripts/generate-tiledata.py > tileset.gbasm @@ -27,4 +27,4 @@ gearboy: build/main.rom gearboy build/main.rom build/main.sym clean: - rm -rf buil1 + rm -rf build diff --git a/definitions.gbasm b/definitions.gbasm index 71912ca..eb756c7 100644 --- a/definitions.gbasm +++ b/definitions.gbasm @@ -139,14 +139,15 @@ .DEFINE mem_stat_jump_instruction $c044 ; takes from c044 to c046 .DEFINE mem_stat_jump_destination $c045 ; takes from c045 to c046 -.DEFINE mem_entity_spawning_pattern ($c046) - .DEFINE mem_number_of_attacks ($c047) .DEFINE mem_cursor_max_position ($c048) .DEFINE mem_learn_attack_dialogue_ret_ptr $c049 ; Takes $c049 and $c04a .DEFINE mem_learn_attack_attack_name_ptr $c04b ; Takes $c04b and $c04c +.DEFINE mem_entity_spawning_pattern ($c04d) +.DEFINE mem_floor_count_bin ($c04e) + ; ## WARNING THE SPACE BETWEEN $c400 and $c800 is used as a buffer for the loading map function during dungeon generation .DEFINE mem_map_loading_buffer $c400 diff --git a/dialogues/demo_quest.gbasm b/dialogues/demo_quest.gbasm index abc462e..f6c36ba 100644 --- a/dialogues/demo_quest.gbasm +++ b/dialogues/demo_quest.gbasm @@ -16,3 +16,4 @@ Demo_quest_floor_reach: .TEXT =Dialogue_3_1t =Dialogue_3_1b .TEXT =Dialogue_3_2t =Dialogue_3_2b .TEXT =Dialogue_3_3t =Empty +.END diff --git a/enemiesattacks/laser.gbasm b/enemiesattacks/laser.gbasm index c26e4e3..9e2f67d 100644 --- a/enemiesattacks/laser.gbasm +++ b/enemiesattacks/laser.gbasm @@ -1,20 +1,4 @@ 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 @@ -65,6 +49,22 @@ Laser_sight_check: ; BC = XY of the enemy. D is unchanged. Direction to face in RET Laser_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: PUSH DE PUSH BC diff --git a/entity/list.gbasm b/entity/list.gbasm index f142505..d32ce95 100644 --- a/entity/list.gbasm +++ b/entity/list.gbasm @@ -130,7 +130,7 @@ Entity_list: .DB $02 ; Starting health - .DB $00 + .DB $01 ; Starting status .DB $00 @@ -104,6 +104,8 @@ Entrypoint: LD $mem_bunny_mana, A LD A, $01 LD $mem_floor_count, A + LD A, $00 + LD $mem_floor_count_bin, A LD HL, $mem_bunny_attacks LD A, $01 @@ -130,6 +132,7 @@ Entrypoint: .INCLUDE "map/generation.gbasm" .INCLUDE "map/objects.gbasm" .INCLUDE "map/generationevents.gbasm" +.INCLUDE "map/dungeons.gbasm" .INCLUDE "gui.gbasm" .INCLUDE "modes/vblank_handler_list.gbasm" .INCLUDE "entity/utils.gbasm" diff --git a/map/dungeons.gbasm b/map/dungeons.gbasm new file mode 100644 index 0000000..dde998a --- /dev/null +++ b/map/dungeons.gbasm @@ -0,0 +1,59 @@ +Load_Dungeon: ; pointer to Dungeon struct in HL + LD A, (HL+) + LD B, A + LD A, (HL+) + LD C, A + + PUSH HL + PUSH BC + LD H, B + LD L, C + + CALL =strlen + LD B, A + + LD A, $14 + SUB B + SRA A + + LD HL, $9e80 + ADD L + LD L, A + LD A, H + ADC $00 + LD H, A + POP BC + CALL =Print_str + + POP HL + + INC HL + + ; TODO FIX THE THING WHEN THERE'S MORE THAN 256/7 FLOORS + LD A, $mem_floor_count + LD C, A + LD B, $07 + CALL =MUL + LD C, A + LD B, (HL) + CALL =MUL + DBG + CALL =RNG_Step + AND $01 + ADD E + DBG + + RET + +Dungeon: + .name: .DB =Dungeon_Name_1_Txt + .max_floor: .DB 0x0a, inv(0x0a) + .spawning_patterns: + .DB $02, $02, $02, $05, 0b10000000 + .DB $02, $02, $03, $05, 0b11000100 + .DB $02, $02, $00, $05, 0b11110100 + .DB $00, $02, $03, $05, 0b10111000 + .DB $02, $02, $00, $05, 0b11111100 + .DB $02, $00, $03, $05, 0b11111000 + .DB $00, $00, $03, $05, 0b11111000 + .DB $00, $00, $03, $05, 0b11111100 diff --git a/map/objects.gbasm b/map/objects.gbasm index 0c1ec51..159caf5 100644 --- a/map/objects.gbasm +++ b/map/objects.gbasm @@ -195,6 +195,10 @@ Stairs_Action: LD $mem_floor_count, A + LD A, $mem_floor_count_bin + INC A + LD $mem_floor_count_bin, A + .skip_update_floor_count: RET diff --git a/modes/dungeongeneration.gbasm b/modes/dungeongeneration.gbasm index 9caa687..20d3036 100644 --- a/modes/dungeongeneration.gbasm +++ b/modes/dungeongeneration.gbasm @@ -32,30 +32,16 @@ New_Dungeon: LD A, $00 LD $mem_display_flag, A - LD HL, =Dungeon_Name_1_Txt - CALL =strlen - LD B, A - - LD A, $14 - SUB B - SRA A - - LD HL, $9e80 - ADD L - LD L, A - LD A, H - ADC $00 - LD H, A - LD BC, =Dungeon_Name_1_Txt - CALL =Print_str + LD HL, =Dungeon + CALL =Load_Dungeon + + LD A, $f4 + LD ($9ecb), A LD HL, $9ec9 LD A, $mem_floor_count CALL =Print_8bit - LD A, $f4 - LD ($9ecb), A - LD A, $07 LD $reg_bg_palette, A diff --git a/utils.gbasm b/utils.gbasm index 38ae74a..7ce588a 100644 --- a/utils.gbasm +++ b/utils.gbasm @@ -220,6 +220,7 @@ Print_str: ; Memory Tilemap position in HL, Text address in BC, FF ended strlen: ; Text address in HL, FF ended. Result in A PUSH HL PUSH BC + LD B, $00 .loop: LD A, (HL+) CP $FF |