From 38bffc0caff4c7eedf70cfb59891151e3fb181f5 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 16 Aug 2017 23:18:59 -0400 Subject: [PATCH] tfv: split files up to be more like C version --- tfv/Makefile | 2 +- tfv/flying.s | 45 +++++++++++++++ tfv/textentry.s | 87 +++++++++++++++++++++++++++++ tfv/tfv.s | 145 ++++-------------------------------------------- tfv/title.s | 47 ++++++++++++++++ 5 files changed, 191 insertions(+), 135 deletions(-) create mode 100644 tfv/flying.s create mode 100644 tfv/textentry.s create mode 100644 tfv/title.s diff --git a/tfv/Makefile b/tfv/Makefile index 6da30e1a..52058e7d 100644 --- a/tfv/Makefile +++ b/tfv/Makefile @@ -48,7 +48,7 @@ backgrounds.inc: $(PNG2RLE) \ TFV: tfv.o ld65 -o TFV tfv.o -C ./apple2_1000.inc -tfv.o: tfv.s opener.s title.s utils.s backgrounds.inc zp.inc +tfv.o: tfv.s flying.s opener.s title.s textentry.s utils.s backgrounds.inc zp.inc ca65 -o tfv.o tfv.s -l tfv.lst diff --git a/tfv/flying.s b/tfv/flying.s new file mode 100644 index 00000000..475a53cb --- /dev/null +++ b/tfv/flying.s @@ -0,0 +1,45 @@ + +flying_start: + + jsr set_gr_page0 + +flying_loop: + jsr gr_copy_to_current + + jsr put_sprite + + jsr wait_until_keypressed + + lda LASTKEY + + cmp #('Q') + bne skipskip + rts +skipskip: + + cmp #('I') + bne check_down + dec YPOS + dec YPOS + +check_down: + cmp #('M') + bne check_left + inc YPOS + inc YPOS + +check_left: + cmp #('J') + bne check_right + dec XPOS + +check_right: + cmp #('K') + bne check_done + inc XPOS + +check_done: + jmp flying_loop + + + diff --git a/tfv/textentry.s b/tfv/textentry.s new file mode 100644 index 00000000..deadfced --- /dev/null +++ b/tfv/textentry.s @@ -0,0 +1,87 @@ +enter_name: + + jsr TEXT + jsr HOME + + lda #>(enter_name_string) + sta OUTH + lda #<(enter_name_string) + sta OUTL + + jsr print_string + + ; zero out name + + lda #<(name) + sta MEMPTRL + sta NAMEL + lda #>(name) + sta MEMPTRH + sta NAMEH + lda #0 + ldx #8 + jsr memset + +name_loop: + + jsr NORMAL + + lda #11 + sta CH ; HTAB 12 + + lda #2 + jsr TABV ; VTAB 3 + + ldy #0 + sty NAMEX + +name_line: + cpy NAMEX + bne name_notx + lda #'+' + jmp name_next + +name_notx: + lda NAMEL,Y + beq name_zero + ora #$80 + bne name_next + +name_zero: + lda #('_'+$80) +name_next: + jsr COUT + lda #(' '+$80) + jsr COUT + iny + cpy #8 + bne name_line + + lda #7 + sta CV + + lda #('@'+$80) + sta CHAR + +print_letters_loop: + lda #11 + sta CH ; HTAB 12 + jsr VTAB + + ldy #0 + +print_letters_inner_loop: + lda CHAR + jsr COUT + inc CHAR + lda #(' '+$80) + jsr COUT + iny + + cpy #$8 + bne print_letters_inner_loop + + jsr wait_until_keypressed + + rts + diff --git a/tfv/tfv.s b/tfv/tfv.s index 51e40cfd..f6b41318 100644 --- a/tfv/tfv.s +++ b/tfv/tfv.s @@ -43,147 +43,22 @@ jsr title_screen -enter_name: + ;====================== + ; get name + ;====================== - jsr TEXT - jsr HOME - - lda #>(enter_name_string) - sta OUTH - lda #<(enter_name_string) - sta OUTL - - jsr print_string - - ; zero out name - - lda #<(name) - sta MEMPTRL - sta NAMEL - lda #>(name) - sta MEMPTRH - sta NAMEH - lda #0 - ldx #8 - jsr memset - -name_loop: - - jsr NORMAL - - lda #11 - sta CH ; HTAB 12 - - lda #2 - jsr TABV ; VTAB 3 - - ldy #0 - sty NAMEX - -name_line: - cpy NAMEX - bne name_notx - lda #'+' - jmp name_next - -name_notx: - lda NAMEL,Y - beq name_zero - ora #$80 - bne name_next - -name_zero: - lda #('_'+$80) -name_next: - jsr COUT - lda #(' '+$80) - jsr COUT - iny - cpy #8 - bne name_line - - lda #7 - sta CV - - lda #('@'+$80) - sta CHAR - -print_letters_loop: - lda #11 - sta CH ; HTAB 12 - jsr VTAB - - ldy #0 - -print_letters_inner_loop: - lda CHAR - jsr COUT - inc CHAR - lda #(' '+$80) - jsr COUT - iny - - cpy #$8 - bne print_letters_inner_loop - - - - - - - jsr wait_until_keypressed + jsr enter_name ;===================== - ; Start the game + ; Flying ;===================== - -flying_start: - - jsr set_gr_page0 - -flying_loop: - jsr gr_copy_to_current - - jsr put_sprite - - jsr wait_until_keypressed - - - - - - lda LASTKEY - - cmp #('Q') - beq exit - - cmp #('I') - bne check_down - dec YPOS - dec YPOS - -check_down: - cmp #('M') - bne check_left - inc YPOS - inc YPOS - -check_left: - cmp #('J') - bne check_right - dec XPOS - -check_right: - cmp #('K') - bne check_done - inc XPOS - -check_done: - jmp flying_loop - + jsr flying_start + ;===================== + ; All finished + ;===================== exit: lda #$4 @@ -207,6 +82,8 @@ exit: .include "opener.s" .include "utils.s" .include "title.s" +.include "textentry.s" +.include "flying.s" ;=============================================== ; Variables diff --git a/tfv/title.s b/tfv/title.s new file mode 100644 index 00000000..5ea6d020 --- /dev/null +++ b/tfv/title.s @@ -0,0 +1,47 @@ + ; Title Screen + +title_screen: + + ;=========================== + ; Clear both bottoms + + lda #$0 + sta DRAW_PAGE + jsr clear_bottom + + lda #$4 + sta DRAW_PAGE + jsr clear_bottom + + ;============================= + ; Load title_rle + + lda #$0c + sta BASH + lda #$00 + sta BASL ; load image off-screen 0xc00 + + lda #>(title_rle) + sta GBASH + lda #<(title_rle) + sta GBASL + jsr load_rle_gr + + ;================================= + ; copy to both pages + + jsr gr_copy_to_current + jsr page_flip + jsr gr_copy_to_current + + lda #20 + sta YPOS + lda #20 + sta XPOS + + ;================================= + ; wait for keypress + + jsr wait_until_keypressed + + rts