Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const word SCREEN0_ADDRESS = $0400;
- const word SPR_PNTR_ADDRESS = SCREEN0_ADDRESS + (2040 - 1024);
- #include <c64.h>
- #include "..\libraries\c64_joy.c"
- #include "..\libraries\c64_vic.c"
- byte sprite[] = {
- 0,127,0,1,255,192,3,255,224,3,231,224,
- 7,217,240,7,223,240,7,217,240,3,231,224,
- 3,255,224,3,255,224,2,255,160,1,127,64,
- 1,62,64,0,156,128,0,156,128,0,73,0,0,73,0,
- 0,62,0,0,62,0,0,62,0,0,28,0
- };
- __address(SPR_PNTR_ADDRESS) byte vic_spr_pntr[8];
- void poke(unsigned word a,unsigned byte v) {
- // write byte v to memory address a
- unsigned char *MEMPTR;
- MEMPTR = (unsigned char *)a;
- *MEMPTR = v;
- }
- byte peek(unsigned word a) {
- // read byte from memory address a
- unsigned char *MEMPTR;
- MEMPTR = (unsigned char *)a;
- return (*MEMPTR);
- }
- const byte SPRITE = 2;
- const byte SCREEN_ORIGIN_X = 24;
- const byte SCREEN_ORIGIN_Y = 50;
- const byte SPRITE_SPEED = 2;
- void main() {
- //ENABLE SPRITE 2
- vic_spr_ena = vic_spr_ena | 4;
- //SPRITE 2 DATA FROM BLOCK 13
- vic_spr_pntr[2] = 13;
- byte i;
- for (i = 0; i < 62; i++) {
- poke(832+i,sprite[i]);
- }
- vic_spr2_x = SCREEN_ORIGIN_X + 255/2;
- vic_spr2_y = SCREEN_ORIGIN_Y + 200/2;
- vic_spr2_color = 1;
- while (true) {
- vic_waitForRaster(251);
- read_joy1();
- read_also_joy2();
- if (input_dx > 0) {vic_spr2_x = vic_spr2_x + SPRITE_SPEED;}
- else if (input_dx < 0) {vic_spr2_x = vic_spr2_x - SPRITE_SPEED;}
- if (input_dy > 0) {vic_spr2_y = vic_spr2_y + SPRITE_SPEED;}
- else if (input_dy < 0) {vic_spr2_y = vic_spr2_y - SPRITE_SPEED;}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement