First cut at separating out platform specific stuff

This commit is contained in:
Rob McMullen 2017-07-25 15:01:06 -07:00
parent 03d912eaba
commit 4e6a8ecf20
5 changed files with 172 additions and 164 deletions

View File

@ -8,48 +8,52 @@ player-missile.hgr: player-missile.png
quicksprite.py player-missile.png
kansasfest-hackfest.hgr: kansasfest-hackfest.png
cp kansasfest-hackfest.png tmphgr-kansasfest-hackfest-top.png
$(TOHGR) tmphgr-kansasfest-hackfest-top.png
cp kansasfest-hackfest.png tmphgr-kansasfest-hackfest-bot.png
quicksprite.py -i bw tmphgr-kansasfest-hackfest-bot.png
quicksprite.py --merge 96 -o kansasfest-hackfest tmphgr-kansasfest-hackfest-top.hgr tmphgr-kansasfest-hackfest-bot.hgr
cp kansasfest-hackfest.png _apple2-kansasfest-hackfest-top.png
$(TOHGR) _apple2-kansasfest-hackfest-top.png
cp kansasfest-hackfest.png _apple2-kansasfest-hackfest-bot.png
quicksprite.py -i bw _apple2-kansasfest-hackfest-bot.png
quicksprite.py --merge 96 -o kansasfest-hackfest _apple2-kansasfest-hackfest-top.hgr _apple2-kansasfest-hackfest-bot.hgr
partycrasher-software.hgr: partycrasher-software.png
cp partycrasher-software.png tmphgr-partycrasher-software-top.png
$(TOHGR) tmphgr-partycrasher-software-top.png
cp partycrasher-software.png tmphgr-partycrasher-software-bot.png
quicksprite.py -i bw tmphgr-partycrasher-software-bot.png
quicksprite.py --merge 116 -o partycrasher-software tmphgr-partycrasher-software-top.hgr tmphgr-partycrasher-software-bot.hgr
cp partycrasher-software.png _apple2-partycrasher-software-top.png
$(TOHGR) _apple2-partycrasher-software-top.png
cp partycrasher-software.png _apple2-partycrasher-software-bot.png
quicksprite.py -i bw _apple2-partycrasher-software-bot.png
quicksprite.py --merge 116 -o partycrasher-software _apple2-partycrasher-software-top.hgr _apple2-partycrasher-software-bot.hgr
title.hgr: title.png
cp title.png tmphgr-title-top.png
$(TOHGR) tmphgr-title-top.png
cp title.png tmphgr-title-bot.png
quicksprite.py -i bw tmphgr-title-bot.png
quicksprite.py --merge 136 167 -o title tmphgr-title-top.hgr tmphgr-title-bot.hgr
cp title.png _apple2-title-top.png
$(TOHGR) _apple2-title-top.png
cp title.png _apple2-title-bot.png
quicksprite.py -i bw _apple2-title-bot.png
quicksprite.py --merge 136 167 -o title _apple2-title-top.hgr _apple2-title-bot.hgr
working-sprite-driver.s: $(SPRITES) fatfont128.dat
quicksprite.py -a mac65 -p 6502 -s hgrbw -m -k -d -g -f fatfont128.dat -o working $(SPRITES)
_apple2-working-sprite-driver.s: $(SPRITES) fatfont128.dat
quicksprite.py -a mac65 -p 6502 -s hgrbw -m -k -d -g -f fatfont128.dat -o _apple2-working $(SPRITES)
working.xex: working.s wipes-null.s main.s constants.s rand.s maze.s working-sprite-driver.s vars.s debug.s actors.s background.s screen.s logic.s
rm -f working.xex
atasm -mae -oworking.xex working.s -Lworking.var -gworking.lst
_apple2-working.xex: wipes-null.s main.s constants.s rand.s maze.s _apple2-working-sprite-driver.s vars.s debug.s actors.s background.s screen.s logic.s platform-apple2.s
rm -f _apple2-working.xex
echo '.include "main.s"' > _apple2-working.s
echo '.include "wipes-null.s"' >> _apple2-working.s
echo '.include "platform-apple2.s"' >> _apple2-working.s
atasm -mae -o_apple2-working.xex _apple2-working.s -L_apple2-working.var -g_apple2-working.lst
working.dsk: working.xex
working.dsk: _apple2-working.xex
rm -f working.dsk
atrcopy working.dsk boot -b working.xex --brun 6000 -f
atrcopy working.dsk boot -b _apple2-working.xex --brun 6000 -f
#cp working.var /home/rob/.wine/drive_c/applewin/APPLE2E.SYM
demo.xex: demo.s wipes-demo.s main.s constants.s rand.s maze.s working-sprite-driver.s vars.s debug.s actors.s background.s screen.s logic.s
rm -f demo.xex
atasm -mae -odemo.xex demo.s -Ldemo.var -gdemo.lst
_apple2-demo.xex: wipes-demo.s main.s constants.s rand.s maze.s _apple2-working-sprite-driver.s vars.s debug.s actors.s background.s screen.s logic.s platform-apple2.s
rm -f _apple2-demo.xex
echo '.include "main.s"' > _apple2-demo.s
echo '.include "wipes-demo.s"' >> _apple2-demo.s
echo '.include "platform-apple2.s"' >> _apple2-demo.s
atasm -mae -o_apple2-demo.xex _apple2-demo.s -L_apple2-demo.var -g_apple2-demo.lst
demo.dsk: demo.xex logic.s player-missile.hgr partycrasher-software.hgr kansasfest-hackfest.hgr title.hgr
atrcopy demo.dsk boot -d partycrasher-software.hgr@2000 player-missile.hgr@4000 kansasfest-hackfest.hgr@2000 title.hgr@4001 -b demo.xex --brun 6000 -f
demo.dsk: _apple2-demo.xex logic.s player-missile.hgr partycrasher-software.hgr kansasfest-hackfest.hgr title.hgr
atrcopy demo.dsk boot -d partycrasher-software.hgr@2000 player-missile.hgr@4000 kansasfest-hackfest.hgr@2000 title.hgr@4001 -b _apple2-demo.xex --brun 6000 -f
clean:
rm -f player-missile.hgr player-missile.hgr.png partycrasher-software.hgr kansasfest-hackfest.hgr title.hgr
rm -f tmphgr-*
rm -f working.dsk working.xex working-*.s
rm -f demo.dsk demo.xex
rm -f _apple2-* working.dsk demo.dsk
rm -f *.lst *.var

2
demo.s
View File

@ -1,2 +0,0 @@
.include "main.s"
.include "wipes-demo.s"

132
main.s
View File

@ -3,18 +3,6 @@
.include "macros.s"
.include "constants.s"
; os memory map
KEYBOARD = $c000
KBDSTROBE = $c010
CLRTEXT = $c050
SETTEXT = $c051
CLRMIXED = $c052
SETMIXED = $c053
TXTPAGE1 = $c054
TXTPAGE2 = $c055
CLRHIRES = $c056
SETHIRES = $c057
; Zero page locations. Using the whole thing because we aren't using any
; ROM routines
@ -121,11 +109,7 @@ frame_count .ds 2
*= $6000
start nop
bit CLRTEXT ; start with HGR page 1, full screen
bit CLRMIXED
bit TXTPAGE1
bit SETHIRES
start jsr set_hires ; start with HGR page 1, full screen
;jsr clrscr
jsr init_once
@ -150,10 +134,7 @@ check_restart ldx #34
jsr printstr ; prints to back page, so have to flip pages to show
jsr pageflip
lda KBDSTROBE ; any key restarts
?1 lda KEYBOARD
bpl ?1
lda KBDSTROBE
jsr any_key
jmp restart
game_text .byte "GAME ",0
@ -167,31 +148,6 @@ init_once
jsr init_actors_once
rts
clrscr
lda #0
sta clr1+1
lda #$20
sta clr1+2
clr0
lda #$81
ldy #0
clr1
sta $ffff,y
iny
bne clr1
inc clr1+2
ldx clr1+2
cpx #$40
bcc clr1
lda #0
ldx #39
?1 jsr text_put_col ; text page 1
jsr text_put_col2 ; text page 2
dex
bpl ?1
rts
title_screen nop
lda #1
sta config_num_players
@ -328,89 +284,6 @@ handle_player nop
userinput
lda KEYBOARD
pha
ldx #38
ldy #23
jsr debughex
ldx #0
pla
bpl input_not_movement ; stop movement of player if no direction input
; setting the keyboard strobe causes the key to enter repeat mode if held
; down, which causes a pause after the initial movement. Not setting the
; strobe allows smooth movement from the start, but there's no way to stop
;sta KBDSTROBE
check_up cmp #$8d ; up arrow
beq input_up
cmp #$c9 ; I
bne check_down
input_up lda #TILE_UP
sta actor_input_dir,x
rts
check_down cmp #$af ; down arrow
beq input_down
cmp #$d4 ; K
bne check_left
input_down lda #TILE_DOWN
sta actor_input_dir,x
rts
check_left cmp #$88 ; left arrow
beq input_left
cmp #$c8 ; J
bne check_right
input_left lda #TILE_LEFT
sta actor_input_dir,x
rts
check_right cmp #$95 ; right arrow
beq input_right
cmp #$ce ; L
bne input_not_movement
input_right lda #TILE_RIGHT
sta actor_input_dir,x
rts
input_not_movement lda #0
sta actor_input_dir,x
check_special cmp #$80 + 32
beq input_space
cmp #$80 + '.'
beq input_period
cmp #$80 + 'P'
beq input_period
rts
input_space
jmp debugflipscreens
input_period
jsr wait
lda KEYBOARD
bpl input_period
cmp #$80 + 'P'
beq input_period
rts
debugflipscreens
lda #20
sta scratch_count
debugloop
jsr pageflip
jsr wait
jsr pageflip
jsr wait
dec scratch_count
bne debugloop
rts
wait
ldy #$06 ; Loop a bit
wait_outer
@ -431,7 +304,6 @@ wait_inner
.include "working-sprite-driver.s"
.include "rand.s"
.include "screen.s"
.include "maze.s"

136
platform-apple2.s Normal file
View File

@ -0,0 +1,136 @@
; os memory map
KEYBOARD = $c000
KBDSTROBE = $c010
CLRTEXT = $c050
SETTEXT = $c051
CLRMIXED = $c052
SETMIXED = $c053
TXTPAGE1 = $c054
TXTPAGE2 = $c055
CLRHIRES = $c056
SETHIRES = $c057
set_hires bit CLRTEXT ; start with HGR page 1, full screen
bit CLRMIXED
bit TXTPAGE1
bit SETHIRES
; wait for any key
any_key lda KBDSTROBE
?1 lda KEYBOARD
bpl ?1
lda KBDSTROBE
rts
; clear all screens, hires and text
clrscr lda #$20
sta clrscr_smc+2
lda #$81
ldy #0
clrscr_smc sta $ff00,y
iny
bne clrscr_smc
inc clrscr_smc+2
ldx clrscr_smc+2
cpx #$40
bcc clrscr_smc
lda #0
ldx #39
?1 jsr text_put_col ; text page 1
jsr text_put_col2 ; text page 2
dex
bpl ?1
rts
; process gameplay user input. Sets actor_input_dir and various debugging
; input
userinput lda KEYBOARD
pha
ldx #38
ldy #23
jsr debughex
ldx #0
pla
bpl input_not_movement ; stop movement of player if no direction input
; setting the keyboard strobe causes the key to enter repeat mode if held
; down, which causes a pause after the initial movement. Not setting the
; strobe allows smooth movement from the start, but there's no way to stop
;sta KBDSTROBE
check_up cmp #$8d ; up arrow
beq input_up
cmp #$c1 ; 'A' key
beq input_up
cmp #$c9 ; I
bne check_down
input_up lda #TILE_UP
sta actor_input_dir,x
rts
check_down cmp #$af ; down arrow
beq input_down
cmp #$bb ; ';' key (dvorak keyboards)
beq input_down
cmp #$da ; 'Z' key
beq input_down
cmp #$d4 ; K
bne check_left
input_down lda #TILE_DOWN
sta actor_input_dir,x
rts
check_left cmp #$88 ; left arrow
beq input_left
cmp #$c8 ; J
bne check_right
input_left lda #TILE_LEFT
sta actor_input_dir,x
rts
check_right cmp #$95 ; right arrow
beq input_right
cmp #$ce ; L
bne input_not_movement
input_right lda #TILE_RIGHT
sta actor_input_dir,x
rts
input_not_movement lda #0
sta actor_input_dir,x
check_special cmp #$80 + 32
beq input_space
cmp #$80 + '.'
beq input_period
cmp #$80 + 'P'
beq input_period
rts
input_space
jmp debugflipscreens
input_period
jsr wait
lda KEYBOARD
bpl input_period
cmp #$80 + 'P'
beq input_period
rts
debugflipscreens
lda #20
sta scratch_count
debugloop
jsr pageflip
jsr wait
jsr pageflip
jsr wait
dec scratch_count
bne debugloop
rts
.include "_apple2-working-sprite-driver.s"

View File

@ -1,2 +0,0 @@
.include "main.s"
.include "wipes-null.s"