From 190822a0dc076f72d40a1744c12481a0c4d2390a Mon Sep 17 00:00:00 2001 From: Rob McMullen Date: Wed, 19 Jul 2017 15:29:05 -0700 Subject: [PATCH] Maze generation working * copy symbols to applewin directory so they'll show up in the debugger! --- Makefile | 5 +- debug.s | 8 ++ fatfont128.dat | Bin 1024 -> 1024 bytes macros.s | 15 +++ maze.s | 150 +++++++++++++++++++++++++--- mazetiles.s | 266 +++++++++++++++++++++++++++++++++++++++++++------ vars.s | 5 + working.s | 20 +++- 8 files changed, 421 insertions(+), 48 deletions(-) create mode 100644 debug.s create mode 100644 macros.s create mode 100644 vars.s diff --git a/Makefile b/Makefile index 1023853..11aee22 100644 --- a/Makefile +++ b/Makefile @@ -32,16 +32,17 @@ partycrasher-software.hgr: partycrasher-software.png titles.dsk: cpbg.xex player-missile.hgr partycrasher-software.hgr kansasfest-hackfest.hgr atrcopy titles.dsk boot -d kansasfest-hackfest.hgr@2000 player-missile.hgr@4000 partycrasher-software.hgr@2000 -b cpbg.xex --brun 6000 -f -working-sprite-driver.s: $(BWSPRITE) +working-sprite-driver.s: $(BWSPRITE) fatfont128.dat quicksprite.py -a mac65 -p 6502 -s hgrbw -m -k -d -g -f fatfont128.dat -o working $(BWSPRITE) -working.xex: working.s rand.s maze.s working-sprite-driver.s +working.xex: working.s rand.s maze.s working-sprite-driver.s vars.s debug.s rm -f working.xex atasm -mae -oworking.xex working.s -Lworking.var -gworking.lst working.dsk: working.xex rm -f working.dsk atrcopy working.dsk boot -b working.xex --brun 6000 -f + cp working.var /home/rob/.wine/drive_c/applewin/APPLE2E.SYM clean: rm -f cpbg.dsk cpbg.xex cpbg.var cpbg.lst cpbg-sprite-driver.s cpbg-bwsprite.s cpbg-hgrcols-7x1.s cpbg-hgrrows.s cpbg-apple_sprite9x11.s cpbg-fastfont.s cpbg-moldy_burger.s diff --git a/debug.s b/debug.s new file mode 100644 index 0000000..89edd0c --- /dev/null +++ b/debug.s @@ -0,0 +1,8 @@ +debugtext nop + sta SETTEXT + sta KBDSTROBE +?1 lda KEYBOARD + sta debug_last_key + cmp #$A0 ; space? + bne ?1 + rts diff --git a/fatfont128.dat b/fatfont128.dat index b93ccb7cd96b332c8e8fa06b4871bf517b3c309a..80b3cf95694c8ae0008ce7646cf58f2318fbe9f5 100644 GIT binary patch delta 201 zcmZqRXyBM25i0@(3miEj>ml;>^&7u(GXntlh8DH} delta 96 VcmZqRXyBM2F;Ren7HAP8GXOUK6@&l) diff --git a/macros.s b/macros.s new file mode 100644 index 0000000..9317a01 --- /dev/null +++ b/macros.s @@ -0,0 +1,15 @@ +.MACRO PUSHAXY + pha + txa + pha + tya + pha +.ENDM + +.MACRO PULLAXY + pla + tay + pla + tax + pla +.ENDM \ No newline at end of file diff --git a/maze.s b/maze.s index bfcf616..6727b7d 100644 --- a/maze.s +++ b/maze.s @@ -38,10 +38,6 @@ player_start_col .byte 255,255,255,255, ; zero players! .byte 7, 19, 31, 0, .byte 1, 13, 25, 31, -amidar_start_col .ds VPATH_NUM -round_robin_up .ds VPATH_NUM -round_robin_down .ds VPATH_NUM - MAZE_TOP_ROW = 1 MAZE_BOT_ROW = 22 SCREEN_ROWS = 24 @@ -83,11 +79,13 @@ mazerow lda textrows_l,y ; y += 1 ; init_boxes() clear_maze nop - ldx #MAZE_RIGHT_COL + ldx #MAZE_LEFT_COL lda #0 ?1 jsr text_put_col - dex - bpl ?1 + inx + cpx #MAZE_RIGHT_COL + bcc ?1 + beq ?1 jmp init_boxes ;# Set all elements in a row to dot + left + right; only top and bottom @@ -100,8 +98,8 @@ clear_maze nop ; row in Y, clobbered setrow jsr mazerow - ldy #MAZE_RIGHT_COL lda #MIDDLE_TILE + ldy #MAZE_RIGHT_COL ?1 sta (mazeaddr),y dey cpy #MAZE_LEFT_COL @@ -166,34 +164,116 @@ setvpath lda vpath_cols,x ;# hpath vertical positioning leaves 2 empty rows, so moving up by one still ;# leaves 1 empty row. ;def sethpath(col): +x1_save .byte 0 +x2 .byte 0 +col_save .byte 0 +row_save .byte 0 + +; X is col, clobbers everything +sethpath PUSHAXY + stx col_save + ; x1_save = vpath_cols[col - 1] + dex + lda vpath_cols,x + sta x1_save + ; x2 = vpath_cols[col] + inx + lda vpath_cols,x + sta x2 + ; y = MAZE_TOP_ROW + ldy #MAZE_TOP_ROW + sty row_save + ; start_box(y, x1_save) + ldx x1_save + jsr start_box + ; y += get_rand_spacing() + jsr get_rand_spacing + sta scratch_row + tya + clc + adc scratch_row + tay + sty row_save + ; while y < MAZE_BOT_ROW - 1: ; addr = mazerow(y) -; +?1 ldy row_save + jsr mazerow + ; # If not working on the rightmost column, check to see there are ; # no cross-throughs. ; if col < VPATH_NUM - 1: + lda col_save + cmp #VPATH_NUM-1 + bcs ?hpath_ok + ; tile = addr[x2] + ldy x2 + lda (mazeaddr),y + ; if tile & TILE_RIGHT: + and #TILE_RIGHT + beq ?hpath_ok + ; maze_log.debug("at y=%d on col %d, found same hpath level at col %d" % (y, col, col + 1)) ; y -= 1 + dec row_save ; addr = mazerow(y) + ldy row_save + jsr mazerow + +?hpath_ok ; add_box(y) + ldy row_save + jsr add_box + ; ; x = x1_save + ldy x1_save + ; addr[x] = TILE_DOT|TILE_UP|TILE_DOWN|TILE_RIGHT + lda #TILE_DOT|TILE_UP|TILE_DOWN|TILE_RIGHT + sta (mazeaddr),y + + lda #TILE_DOT|TILE_LEFT|TILE_RIGHT ; x += 1 + iny + ; while x < x2: +?2 ; addr[x] = TILE_DOT|TILE_LEFT|TILE_RIGHT + sta (mazeaddr),y + ; x += 1 + iny + cpy x2 + bcc ?2 ; addr[x2] = TILE_DOT|TILE_UP|TILE_DOWN|TILE_LEFT + lda #TILE_DOT|TILE_UP|TILE_DOWN|TILE_LEFT + sta (mazeaddr),y + ; y += get_rand_spacing() + jsr get_rand_spacing + clc + adc row_save + sta row_save + cmp #MAZE_BOT_ROW-1 + bcc ?1 + ; add_box(MAZE_BOT_ROW) -; + ldy #MAZE_BOT_ROW + jsr add_box + + PULLAXY + rts + + + ; ;def init_maze(): ; clear_maze() @@ -228,10 +308,20 @@ init_maze nop ldy #MAZE_BOT_ROW jsr setrow ldx #VPATH_NUM + stx maze_gen_col ?1 dex jsr setvpath cpx #0 bne ?1 + + ldx #VPATH_NUM +?2 dex + jsr sethpath + cpx #1 + bne ?2 + + jsr finish_boxes + rts ;##### Box handling/painting @@ -267,9 +357,10 @@ init_maze nop ;# 03 X|XXXXX|XXXXX|XXXXX|XXXXX|XXXXX|X_______ ;# 04 X|XXXXX|XXXXX|XXXXX+-----+XXXXX|X_______ ; -;NUM_LEVEL_BOX_PARAMS = 3 -;level_boxes = [0] * 10 * 6 * NUM_LEVEL_BOX_PARAMS -; +NUM_LEVEL_BOX_PARAMS = 3 +;level_boxes .ds 10*6*NUM_LEVEL_BOX_PARAMS +level_boxes = $bd00 + ;# Box painting will be in hires so this array will become a tracker for the ;# hires display. It will need y address, y end address, x byte number. It's ;# possible for up to 3 boxes to get triggered to start painting when collecting @@ -290,6 +381,13 @@ init_boxes nop ;def start_box(r, c): ; zp.box_col_save = c ; zp.box_row_save = r + +; col in X, row in Y +start_box nop + stx box_col_save + sty box_row_save + rts + ; ;def add_box(r): ; i = zp.next_level_box @@ -298,11 +396,33 @@ init_boxes nop ; level_boxes[i + 2] = r ; zp.box_row_save = r ; zp.next_level_box += NUM_LEVEL_BOX_PARAMS -; +add_box nop + ldx next_level_box + lda box_col_save + sta level_boxes,x + inx + lda box_row_save + sta level_boxes,x + inx + tya + sta level_boxes,x + sta box_row_save + inx + stx next_level_box + rts + + ;def finish_boxes(): ; i = zp.next_level_box ; level_boxes[i] = 0xff -; +finish_boxes nop + ldx next_level_box + lda #$ff + sta level_boxes,x + rts + + + ;def check_boxes(): ; x = 0 ; pad.addstr(28, 0, str(level_boxes[0:21])) diff --git a/mazetiles.s b/mazetiles.s index 4e2f662..5d7997f 100644 --- a/mazetiles.s +++ b/mazetiles.s @@ -1,5 +1,146 @@ +; these characters will be reversed using Omnivore, so the bits are as +; they will appear on screen, not reversed as in screen memory. Bit 9 +; is the "high bit" for the palette selection, as defined below. + + *= $b000 + fatfont_maze ; curseschars = [ +; curses.ACS_CKBOARD, # illegal + .byte 0,0,0,0,0,0,0,0 + +; curses.ACS_CKBOARD, + .byte 0,0,0,0,0,0,0,0 + +; curses.ACS_CKBOARD, + .byte 0,0,0,0,0,0,0,0 + +; curses.ACS_VLINE, # 3: up/down + .byte %00101000 + .byte %00101000 + .byte %00101000 + .byte %00101000 + .byte %00101000 + .byte %00101000 + .byte %00101000 + .byte %00101000 + +; curses.ACS_CKBOARD, + .byte 0,0,0,0,0,0,0,0 + +; curses.ACS_ULCORNER, # 5: down/right + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00101010 + .byte %00101010 + .byte %00101000 + .byte %00101000 + .byte %00101000 + +; curses.ACS_LLCORNER, # 6: up/right + .byte %00101000 + .byte %00101000 + .byte %00101000 + .byte %00101010 + .byte %00101010 + .byte %00000000 + .byte %00000000 + .byte %00000000 + +; curses.ACS_LTEE, # 7: up/down/right + .byte %00101000 + .byte %00101000 + .byte %00101000 + .byte %00101010 + .byte %00101010 + .byte %00101000 + .byte %00101000 + .byte %00101000 + +; curses.ACS_CKBOARD, + .byte 0,0,0,0,0,0,0,0 + +; curses.ACS_URCORNER, # 9: left/down + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %10101000 + .byte %10101000 + .byte %00101000 + .byte %00101000 + .byte %00101000 + +; curses.ACS_LRCORNER, # 10: left/up + .byte %00101000 + .byte %00101000 + .byte %00101000 + .byte %10101000 + .byte %10101000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + +; curses.ACS_RTEE, # 10: left/up/down + .byte %00101000 + .byte %00101000 + .byte %00101000 + .byte %10101000 + .byte %10101000 + .byte %00101000 + .byte %00101000 + .byte %00101000 + +; curses.ACS_HLINE, # 12: left/right + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %10101010 + .byte %10101010 + .byte %00000000 + .byte %00000000 + .byte %00000000 + +; curses.ACS_TTEE, # 13: left/right/down + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %10101010 + .byte %10101010 + .byte %00101000 + .byte %00101000 + .byte %00101000 + +; curses.ACS_BTEE, # 14: left/right/up + .byte %00101000 + .byte %00101000 + .byte %00101000 + .byte %10101010 + .byte %10101010 + .byte %00000000 + .byte %00000000 + .byte %00000000 + +; curses.ACS_HLINE, # 15: alternate left/right + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %01010100 + .byte %01010100 + .byte %00000000 + .byte %00000000 + .byte %00000000 + + + + + + +; # And same again, with dots + + + + ; curses.ACS_CKBOARD, # illegal .byte 0,0,0,0,0,0,0,0 @@ -23,34 +164,99 @@ fatfont_maze .byte 0,0,0,0,0,0,0,0 ; curses.ACS_ULCORNER, # 5: down/right -; curses.ACS_LLCORNER, # 6: up/right -; curses.ACS_LTEE, # 7: up/down/right -; curses.ACS_CKBOARD, -; curses.ACS_URCORNER, # 9: left/down -; curses.ACS_LRCORNER, # 10: left/up -; curses.ACS_RTEE, # 11: left/up/down -; curses.ACS_HLINE, # 12: left/right -; curses.ACS_TTEE, # 13: left/right/down -; curses.ACS_BTEE, # 14: left/right/up -; curses.ACS_CKBOARD, -; -; # And same again, with dots -; curses.ACS_CKBOARD, # illegal -; curses.ACS_CKBOARD, -; curses.ACS_CKBOARD, -; curses.ACS_VLINE, # 3: up/down -; curses.ACS_CKBOARD, -; curses.ACS_ULCORNER, # 5: down/right -; curses.ACS_LLCORNER, # 6: up/right -; curses.ACS_LTEE, # 7: up/down/right -; curses.ACS_CKBOARD, -; curses.ACS_URCORNER, # 9: left/down -; curses.ACS_LRCORNER, # 10: left/up -; curses.ACS_RTEE, # 11: left/up/down -; curses.ACS_HLINE, # 12: left/right -; curses.ACS_TTEE, # 13: left/right/down -; curses.ACS_BTEE, # 14: left/right/up -; curses.ACS_CKBOARD, -; ] + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00111110 + .byte %00111110 + .byte %00111000 + .byte %00111000 + .byte %00111000 + +; curses.ACS_LLCORNER, # 6: up/right + .byte %00111000 + .byte %00111000 + .byte %00111000 + .byte %00111110 + .byte %00111110 + .byte %00000000 + .byte %00000000 + .byte %00000000 + +; curses.ACS_LTEE, # 7: up/down/right + .byte %00111000 + .byte %00111000 + .byte %00111000 + .byte %00111111 + .byte %00111111 + .byte %00111000 + .byte %00111000 + .byte %00111000 + +; curses.ACS_CKBOARD, + .byte 0,0,0,0,0,0,0,0 + +; curses.ACS_URCORNER, # 9: left/down + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %11111000 + .byte %11111000 + .byte %00111000 + .byte %00111000 + .byte %00111000 + +; curses.ACS_LRCORNER, # 10: left/up + .byte %00111000 + .byte %00111000 + .byte %00111000 + .byte %11111000 + .byte %11111000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + +; curses.ACS_RTEE, # 11: left/up/down + .byte %00111000 + .byte %00111000 + .byte %00111000 + .byte %11111000 + .byte %11111000 + .byte %00111000 + .byte %00111000 + .byte %00111000 + +; curses.ACS_HLINE, # 12: left/right + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %11111110 + .byte %11111110 + .byte %00000000 + .byte %00000000 + .byte %00000000 + +; curses.ACS_TTEE, # 13: left/right/down + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %11111110 + .byte %11111110 + .byte %00111000 + .byte %00111000 + .byte %00111000 + +; curses.ACS_BTEE, # 14: left/right/up + .byte %00111000 + .byte %00111000 + .byte %00111000 + .byte %11111110 + .byte %11111110 + .byte %00000000 + .byte %00000000 + .byte %00000000 + +; curses.ACS_CKBOARD, + .byte 0,0,0,0,0,0,0,0 + - .byte % diff --git a/vars.s b/vars.s new file mode 100644 index 0000000..103b2fb --- /dev/null +++ b/vars.s @@ -0,0 +1,5 @@ + *= $800 + +amidar_start_col .ds VPATH_NUM +round_robin_up .ds VPATH_NUM +round_robin_down .ds VPATH_NUM diff --git a/working.s b/working.s index f6450c7..c0e9da4 100644 --- a/working.s +++ b/working.s @@ -1,5 +1,7 @@ *= $6000 +.include "macros.s" + ; os memory map KEYBOARD = $c000 KBDSTROBE = $c010 @@ -63,8 +65,16 @@ tempcol .ds 1 *= $0040 mazeaddr .ds 2 next_level_box .ds 1 +box_row_save .ds 1 +box_col_save .ds 1 +maze_gen_col .ds 1 +; memory map +; BF00 - BFFF: damage for page 1 +; BE00 - BEFF: damage for page 2 +; BD00 - BDFF: level box storage + ; constants DAMAGEPAGE1 = $bf ; page number of damage list for screen 1 @@ -74,6 +84,12 @@ MAXPOSY = 192 - 16 *= $80 + *= $f0 +debug_a .ds 1 +debug_x .ds 1 +debug_y .ds 1 +debug_last_key .ds 1 + *= $6000 @@ -121,5 +137,7 @@ game_loop nop .include "rand.s" .include "screen.s" .include "maze.s" +.include "debug.s" - +; vars must be last +.include "vars.s"