A dungeon delver roguelike using Pathfinder 2nd edition rules
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Beginning to code the dungeon functions

+102 -7
+77 -5
gb/src/dungeon.asm
··· 1 1 SECTION "DungeonVariables", WRAM0 2 2 3 - wDungeonGrid:: ds 512 4 - wEntranceId:: db 5 - wCurrentRoom:: db 6 - wCurrentWidth:: db 7 - wCurrentHeight:: db 3 + dungeon_grid:: ds 512 4 + entrance_id:: db 5 + current_room:: db 6 + current_width:: db 7 + current_height:: db 8 + generated_cells:: ds 512 9 + 10 + SECTION "DungeonCode", ROM0 11 + 12 + ; Params: 13 + ; Starting Width: B 14 + ; Starting Height: C 15 + InitDungeon:: 16 + ld hl, current_width 17 + ld [hl], b 18 + ld hl, current_height 19 + ld [hl], c 20 + ret 21 + 22 + GenerateDungeon:: 23 + ; Dungeon Area = E 24 + push de 25 + push hl 26 + push af 27 + push bc 28 + 29 + ld hl, current_width 30 + ld e, [hl] 31 + ld d, 0 32 + ld hl, current_height 33 + ld a, [hl] 34 + call Mul8 35 + ld d, h 36 + ld e, l 37 + 38 + ; Generated Cells Number = A 39 + ld a, 0 40 + 41 + ; i = B 42 + ld b, 0 43 + .LoopCheck: 44 + cp a, e 45 + jp nz, GenerateDungeon.Loop_Skip 46 + jp nc, GenerateDungeon.Loop_Skip 47 + jp GenerateDungeon.LoopCheck2 48 + .LoopCheck2: 49 + push af 50 + ld a, b 51 + cp a, 0 52 + pop af 53 + jp z, GenerateDungeon.Loop_Body 54 + push af 55 + push bc 56 + ld c, a 57 + ld a, b 58 + ld b, c 59 + cp a, b 60 + pop bc 61 + pop af 62 + jp nz, GenerateDungeon.Loop_Skip 63 + jp nc, GenerateDungeon.Loop_Skip 64 + .Loop_Body: 65 + push af 66 + ld a, b 67 + cp a, 0 68 + pop af 69 + jp nz, GenerateDungeon.Loop_Body2 70 + cp a, 0 71 + jp nz, GenerateDungeon.Loop_Body2 72 + .Loop_Body2: 73 + .Loop_Skip: 74 + pop bc 75 + pop af 76 + pop hl 77 + pop de 78 + 79 + ret
+7 -2
gb/src/main.asm
··· 23 23 SECTION "Entry point", ROM0 24 24 25 25 EntryPoint: 26 - ; Here is where the fun begins, happy coding :) 26 + ; Seed random number generator 27 27 ld b, 0 28 28 ld c, 10 29 29 call srand 30 - call rand 30 + 31 + ; Initialize Dungeon 32 + ld b, 6 33 + ld c, 6 34 + call InitDungeon 35 + 31 36 jp Done 32 37 33 38 Done:
+18
gb/src/utils.asm
··· 7 7 ; C=state bits 23-16, HL trashed 8 8 rand:: 9 9 ; Add 0xB3 then multiply by 0x01010101 10 + push hl 11 + push af 10 12 ld hl, randstate+0 11 13 ld a, [hl] 12 14 add a, $B3 ··· 19 21 adc a, [hl] 20 22 ld [hl], a 21 23 ld b, a 24 + pop af 25 + pop hl 22 26 ret 23 27 24 28 ; Sets the random seed to BC. ··· 32 36 ld a,b 33 37 ld [hl-],a 34 38 ld [hl],c 39 + ret 40 + 41 + ; HL = DE * A 42 + Mul8:: 43 + ld hl, 0 44 + ld b, 8 45 + Mul8Loop: 46 + rrca 47 + jp nc, Mul8Skip 48 + add hl, de 49 + Mul8Skip: 50 + sla e 51 + rl d 52 + STOP 35 53 ret