diff --git a/chiptune_player/Makefile b/chiptune_player/Makefile index 24688242..d821d3dd 100644 --- a/chiptune_player/Makefile +++ b/chiptune_player/Makefile @@ -17,6 +17,7 @@ CHIPTUNE_PLAYER: chiptune_player.o chiptune_player.o: chiptune_player.s \ ../asm_routines/mockingboard.s \ ../asm_routines/dos33_routines.s \ + rasterbars.s \ chip_title.inc zp.inc ca65 -o chiptune_player.o chiptune_player.s -l chiptune_player.lst diff --git a/chiptune_player/chiptune_player.s b/chiptune_player/chiptune_player.s index 7649c441..ff1136f7 100644 --- a/chiptune_player/chiptune_player.s +++ b/chiptune_player/chiptune_player.s @@ -141,15 +141,12 @@ mockingboard_found: ;============================ ; Init Background ;============================ -; jsr clear_screens ; clear top/bottom of page 0/1 -; jsr set_gr_page0 + jsr clear_screens ; clear top/bottom of page 0/1 + jsr set_gr_page0 -; lda #0 -; sta DRAW_PAGE -; sta RANDOM_POINTER -; sta SCREEN_Y - ; always multiply with low byte as zero -; sta NUM2L + lda #0 + sta DRAW_PAGE + sta SCREEN_Y ;============================ ; Loop forever @@ -158,10 +155,13 @@ playing_loop: ;============================ - ; starfield + ; rasters ;============================ -; jsr starfield + jsr clear_top + + jsr draw_rasters + jsr page_flip lda DONE_PLAYING beq playing_loop @@ -270,6 +270,9 @@ done_interrupt: .include "../asm_routines/gr_unrle.s" .include "../asm_routines/gr_setpage.s" .include "../asm_routines/dos33_routines.s" +.include "../asm_routines/gr_hlin.s" +.include "rasterbars.s" + ;======= ; music diff --git a/chiptune_player/rasterbars.s b/chiptune_player/rasterbars.s new file mode 100644 index 00000000..bbab20de --- /dev/null +++ b/chiptune_player/rasterbars.s @@ -0,0 +1,244 @@ +; Not quite a raster-bar, but why not + +;=========== +; CONSTANTS +;=========== + +ELEMENTS EQU 64 +NUM_ROWS EQU 20 + + ;===================== + ; Rasterbars + ;===================== + + ;=========================== + ;=========================== + ; Main Loop + ;=========================== + ;=========================== +draw_rasters: + + ; clear rows + + ldy #(NUM_ROWS-1) ; 2 + lda #0 ; 2 + +init_rows: + sta row_color,Y ; 5 + dey ; 2 + bpl init_rows ; 2nt/3 + + ;================ + ; set colors + + lda #COLOR_BOTH_AQUA ; aqua + ldy SCREEN_Y + jsr set_row_color + + lda #COLOR_BOTH_MEDIUMBLUE ; medium blue + jsr set_row_color + + lda #COLOR_BOTH_LIGHTGREEN ; light green + jsr set_row_color + + lda #COLOR_BOTH_DARKGREEN ; green + jsr set_row_color + + lda #COLOR_BOTH_YELLOW ; yellow + jsr set_row_color + + lda #COLOR_BOTH_ORANGE ; orange + jsr set_row_color + + lda #COLOR_BOTH_PINK ; pink + jsr set_row_color + + lda #COLOR_BOTH_RED ; red + jsr set_row_color + + ;================= + ; draw rows + + ldy #(NUM_ROWS-1) ; 2 +draw_rows_loop: + lda row_color,Y ; 5 + beq draw_rows_skip ; skip if black ; 2nt/3 + + sta COLOR ; 3 + + + tya ; 2 + pha ; 3 + asl ; 2 + + ldy #39 ; 2 + sty V2 ; 3 + ldy #0 ; 2 + jsr hlin_double ; hlin y,V2 at A ; 63+(X*16) + pla ; 4 + tay ; 2 +draw_rows_skip: + dey ; 2 + bpl draw_rows_loop ; 2 + + ;================== + ; update y pointer + ;================== + ldy SCREEN_Y + iny + cpy #ELEMENTS + bne not_there + ldy #0 +not_there: + sty SCREEN_Y + + + rts + + ;=================== + ;=================== + ; set_row_color + ;=================== + ;=================== + ; color in A + ; Y=offset + ; Y incremented + ; A, X trashed + +set_row_color: + sta COLOR + tya ; wrap y offset + and #(ELEMENTS-1) + tax + + lda fine_sine,X ; lookup sine value + ; pre-shifted right by 4, sign-extended + + clc + adc #18 ; add in 18 to center on screen + +sin_no_more: + + pha ; save row value + jsr put_color ; put color at row + pla ; restore row value + + clc ; increment row value + adc #1 + + jsr put_color ; put color at row + + iny ; increment for next time + + rts + + ;================== + ; put_color + ;================== + ; A = row to set color of + ; A trashed +put_color: + clc + ror ; row/2, with even/odd in carry + tax ; put row/2 in X + + bcc even_line ; if even, skip to even +odd_line: + lda #$f0 ; load mask for odd + bcs finish_line +even_line: + lda #$0f ; load mask for even +finish_line: + sta MASK + + and COLOR ; mask off color + sta COLOR2 ; store for later + + lda MASK + eor #$ff ; invert mask + and row_color,X ; load existing color + + ora COLOR2 ; combine + sta row_color,X ; store back + + rts + +;====================== +; some arrays +;====================== + +row_color: +.byte $00,$00,$00,$00,$00, $00,$00,$00,$00,$00 +.byte $00,$00,$00,$00,$00, $00,$00,$00,$00,$00 + +; arithmatically shifted right by 4 + +; FIXME: exploit symmetry and get rid of 3/4 of this table +; possibly not worth the extra code +fine_sine: +.byte $00 ; 0.000000 +.byte $01 ; 0.098017 +.byte $03 ; 0.195090 +.byte $04 ; 0.290285 +.byte $06 ; 0.382683 +.byte $07 ; 0.471397 +.byte $08 ; 0.555570 +.byte $0A ; 0.634393 +.byte $0B ; 0.707107 +.byte $0C ; 0.773010 +.byte $0D ; 0.831470 +.byte $0E ; 0.881921 +.byte $0E ; 0.923880 +.byte $0F ; 0.956940 +.byte $0F ; 0.980785 +.byte $0F ; 0.995185 +.byte $0F ; 1.000000 +.byte $0F ; 0.995185 +.byte $0F ; 0.980785 +.byte $0F ; 0.956940 +.byte $0E ; 0.923880 +.byte $0E ; 0.881921 +.byte $0D ; 0.831470 +.byte $0C ; 0.773010 +.byte $0B ; 0.707107 +.byte $0A ; 0.634393 +.byte $08 ; 0.555570 +.byte $07 ; 0.471397 +.byte $06 ; 0.382683 +.byte $04 ; 0.290285 +.byte $03 ; 0.195090 +.byte $01 ; 0.098017 +.byte $00 ; 0.000000 + +.byte $FE ; -0.098017 +.byte $FC ; -0.195090 +.byte $FB ; -0.290285 +.byte $F9 ; -0.382683 +.byte $F8 ; -0.471397 +.byte $F7 ; -0.555570 +.byte $F5 ; -0.634393 +.byte $F4 ; -0.707107 +.byte $F3 ; -0.773010 +.byte $F2 ; -0.831470 +.byte $F1 ; -0.881921 +.byte $F1 ; -0.923880 +.byte $F0 ; -0.956940 +.byte $F0 ; -0.980785 +.byte $F0 ; -0.995185 +.byte $F0 ; -1.000000 +.byte $F0 ; -0.995185 +.byte $F0 ; -0.980785 +.byte $F0 ; -0.956940 +.byte $F1 ; -0.923880 +.byte $F1 ; -0.881921 +.byte $F2 ; -0.831470 +.byte $F3 ; -0.773010 +.byte $F4 ; -0.707107 +.byte $F5 ; -0.634393 +.byte $F7 ; -0.555570 +.byte $F8 ; -0.471397 +.byte $F9 ; -0.382683 +.byte $FB ; -0.290285 +.byte $FC ; -0.195090 +.byte $FE ; -0.098017 + diff --git a/chiptune_player/zp.inc b/chiptune_player/zp.inc index b6b9f301..55ff4d03 100644 --- a/chiptune_player/zp.inc +++ b/chiptune_player/zp.inc @@ -2,18 +2,18 @@ ;; Zero page monitor routines addresses - ;WNDLFT EQU $20 - ;WNDWDTH EQU $21 - ;WNDTOP EQU $22 - ;WNDBTM EQU $23 +WNDLFT EQU $20 +WNDWDTH EQU $21 +WNDTOP EQU $22 +WNDBTM EQU $23 CH EQU $24 CV EQU $25 GBASL EQU $26 GBASH EQU $27 BASL EQU $28 BASH EQU $29 - ;H2 EQU $2C - ;V2 EQU $2D +H2 EQU $2C +V2 EQU $2D MASK EQU $2E COLOR EQU $30 ;INVFLG EQU $32 @@ -21,60 +21,58 @@ COLOR EQU $30 ; dos33 zero page = 26-2f, 35-38, 3e 3f 40-4d ; overlap applesoft 67-6a,6f,70,af,b0,ca-cd,d8 -RWTSL EQU $60 -RWTSH EQU $61 -DOSBUFL EQU $62 -DOSBUFH EQU $63 -FILEML EQU $64 -FILEMH EQU $65 - - - ;TURNING EQU $60 - ;SCREEN_X EQU $61 ; not used? +RWTSL EQU $60 +RWTSH EQU $61 +DOSBUFL EQU $62 +DOSBUFH EQU $63 +FILEML EQU $64 +FILEMH EQU $65 + ;TURNING EQU $60 + ;SCREEN_X EQU $61 ; not used? SCREEN_Y EQU $62 -;ANGLE EQU $63 -;HORIZ_SCALE_I EQU $64 -;HORIZ_SCALE_F EQU $65 -;FACTOR_I EQU $66 -;FACTOR_F EQU $67 -;DX_I EQU $68 -;DX_F EQU $69 -;SPACEX_I EQU $6A -;SPACEX_F EQU $6B -;CX_I EQU $6C -;CX_F EQU $6D -;DY_I EQU $6E -;DY_F EQU $6F + ;ANGLE EQU $63 + ;HORIZ_SCALE_I EQU $64 + ;HORIZ_SCALE_F EQU $65 + ;FACTOR_I EQU $66 + ;FACTOR_F EQU $67 + ;DX_I EQU $68 + ;DX_F EQU $69 + ;SPACEX_I EQU $6A + ;SPACEX_F EQU $6B + ;CX_I EQU $6C + ;CX_F EQU $6D + ;DY_I EQU $6E + ;DY_F EQU $6F + ;SPACEY_I EQU $70 + ;SPACEY_F EQU $71 + ;CY_I EQU $72 + ;CY_F EQU $73 + ;TEMP_I EQU $74 + ;TEMP_F EQU $75 + ;DISTANCE_I EQU $76 + ;DISTANCE_F EQU $77 + ;SPACEZ_I EQU $78 + ;SPACEZ_F EQU $79 + ;DRAW_SPLASH EQU $7A + ;SPEED EQU $7B + ;SPLASH_COUNT EQU $7C + ;OVER_LAND EQU $7D + ;NUM1L EQU $7E + ;NUM1H EQU $7F -;SPACEY_I EQU $70 -;SPACEY_F EQU $71 -;CY_I EQU $72 -;CY_F EQU $73 -;TEMP_I EQU $74 -;TEMP_F EQU $75 -;DISTANCE_I EQU $76 -;DISTANCE_F EQU $77 -;SPACEZ_I EQU $78 -;SPACEZ_F EQU $79 -;DRAW_SPLASH EQU $7A -;SPEED EQU $7B -;SPLASH_COUNT EQU $7C - ;OVER_LAND EQU $7D -NUM1L EQU $7E -NUM1H EQU $7F -NUM2L EQU $80 -NUM2H EQU $81 -RESULT EQU $82 ; 83,84,85 - ;NEGATE EQU $86 ; UNUSED? - ;LAST_SPACEX_I EQU $87 - ;LAST_SPACEY_I EQU $88 - ;LAST_MAP_COLOR EQU $89 - ;DRAW_SKY EQU $8A + ;NUM2L EQU $80 + ;NUM2H EQU $81 + ;RESULT EQU $82 ; 83,84,85 + ;NEGATE EQU $86 ; UNUSED? + ;LAST_SPACEX_I EQU $87 + ;LAST_SPACEY_I EQU $88 + ;LAST_MAP_COLOR EQU $89 + ;DRAW_SKY EQU $8A COLOR_MASK EQU $8B - ;KEY_COUNT EQU $8C - ;KEY_OFFSET EQU $8D - ;DRAW_BLUE_SKY EQU $8E + ;KEY_COUNT EQU $8C + ;KEY_OFFSET EQU $8D + ;DRAW_BLUE_SKY EQU $8E RANDOM_POINTER EQU $8F FRAME_COUNT EQU $90 MB_VALUE EQU $91 @@ -94,16 +92,16 @@ MB_FRAME_DIFF EQU $94 ; More zero-page addresses ; we try not to conflict with anything DOS, MONITOR or BASIC related - ;COLOR1 EQU $E0 - ;COLOR2 EQU $E1 - ;MATCH EQU $E2 + ;COLOR1 EQU $E0 +COLOR2 EQU $E1 + ;MATCH EQU $E2 XX EQU $E3 - ;YY EQU $E4 - ;SHIPY EQU $E4 - ;YADD EQU $E5 - ;LOOP EQU $E6 - ;MEMPTRL EQU $E7 - ;MEMPTRH EQU $E8 + ;YY EQU $E4 + ;SHIPY EQU $E4 + ;YADD EQU $E5 + ;LOOP EQU $E6 + ;MEMPTRL EQU $E7 + ;MEMPTRH EQU $E8 ;NAMEL EQU $E9 ;NAMEH EQU $EA ;NAMEX EQU $EB @@ -119,7 +117,7 @@ YPOS EQU $F4 TEMP EQU $FA ;RUN EQU $FA ;TEMP2 EQU $FB - ;TEMPY EQU $FB +TEMPY EQU $FB INL EQU $FC INH EQU $FD OUTL EQU $FE @@ -127,10 +125,6 @@ OUTH EQU $FF - - - - KEYPRESS EQU $C000 KEYRESET EQU $C010