Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pseudoOps.asm"
- #define center (128-18)/2
- ;this computes sin by grabbing from sin_table
- #define sin8_i_shift(_shft) \
- lda @,sin_table &&\
- shr(#,_shft) && sta $,_SCRATCH_C &&\
- and #,0x80>>_shft && bnz @+2+3 &&\
- lda #,0 && jmp @+3+2 &&\
- lda #,_l(0xff00>>_shft) &&\
- ora_abs(_SCRATCH_C)
- ;program start
- jmp 0x200 ;so i can potentially use 0x02 -> 0x1ff for whatever
- !@= 0x200
- set_canvas(#,3) ;switch canvas size to 128x128 (16x16 * 2^3)
- :start: ldc_imm(0xc000) ;start of vram
- :loop:
- rand ;load random byte into A
- sta ^ ;store random byte at address C
- inc ;increment C
- bcnz_imm(loop) ;break loop if C wraps back to 0
- ldi_abs ball_radians ;
- sin8_i_shift(2) && add #,center ;
- sta $,ball_sprite ;
- ini && ini && ini ;
- sti $,ball_radians ;;
- ldi_abs ball_radians+1 ;
- sin8_i_shift(2) && add #,center ;
- sta $,ball_sprite+1 ;
- ini && ini && ini && ini ;
- sti $,ball_radians+1 ;;
- ldc_imm(ball_sprite) && sys #,5 ;blit circle sprite to screen
- get_key(#,'a') ;put boolean state of keyboard key "a" into A
- bnz .s ;if boolean true, skip to line 12
- wait_frames(#,1) ;if "a" not pressed, wait additional 8 frames
- .s: wait_frames(#,1) ;^^(basically, pressing "a" makes the speed 2x)
- jmp start
- :ball_radians: !8 64,0 ;for cos,sin; =value * about .025 radians
- ;the ball sprite that moves around
- #define a 231
- #define b 255
- #define c 254
- #define d 253
- #define e 188
- #define f 252
- #define g 251
- #define h 250
- #define i 249
- #define j 145
- :ball_sprite: !8 center,center, 18,18
- !8 0,0,0,0,0,0,a,a,a,a,a,a,0,0,0,0,0,0
- !8 0,0,0,0,a,a,b,b,b,b,b,b,a,a,0,0,0,0
- !8 0,0,0,a,b,b,c,c,c,c,c,c,b,b,a,0,0,0
- !8 0,0,a,b,c,c,d,d,d,d,d,d,c,c,b,a,0,0
- !8 0,a,b,c,d,d,e,e,e,e,e,e,d,d,c,b,a,0
- !8 0,a,b,c,d,e,f,f,f,f,f,f,e,d,c,b,a,0
- !8 a,b,c,d,e,f,g,g,g,g,g,g,f,e,d,c,b,a
- !8 a,b,c,d,e,f,g,h,i,i,h,g,f,e,d,c,b,a
- !8 a,b,c,d,e,f,g,i,j,j,i,g,f,e,d,c,b,a ;
- !8 a,b,c,d,e,f,g,i,j,j,i,g,f,e,d,c,b,a ;
- !8 a,b,c,d,e,f,g,h,i,i,h,g,f,e,d,c,b,a
- !8 a,b,c,d,e,f,g,g,g,g,g,g,f,e,d,c,b,a
- !8 0,a,b,c,d,e,f,f,f,f,f,f,e,d,c,b,a,0
- !8 0,a,b,c,d,d,e,e,e,e,e,e,d,d,c,b,a,0
- !8 0,0,a,b,c,c,d,d,d,d,d,d,c,c,b,a,0,0
- !8 0,0,0,a,b,b,c,c,c,c,c,c,b,b,a,0,0,0
- !8 0,0,0,0,a,a,b,b,b,b,b,b,a,a,0,0,0,0
- !8 0,0,0,0,0,0,a,a,a,a,a,a,0,0,0,0,0,0
- :sin_table: !bin "gen/sin256_8.bin" ;sin lookup table
- !savlbl "labels.txt" && !to "program.bin" && !save
Add Comment
Please, Sign In to add comment