Hallo, guten Abend.
Die Spritecolli funktioniert nicht beim C128 mit dem Hintergrund. Der Buchstabe "a" befindet sich in der mitte vom Screen.
Das Sprite lässt sich steuern. Beim C64 funktioniert es.
Muss man beim C128 noch irgendein ROM zugänglich schalten, damit die Collision erkannt wird?
danke.
gruss
C
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <peekpoke.h>
#define sprite0_data 0x0e00
#define JOY2 0xDC00
#define JOYUP 0x01
#define JOYDOWN 0x02
#define JOYLEFT 0x04
#define JOYRIGHT 0x08
#define JOYFIRE 0x10
#define WAIT_WHILE_RASTERLINE_LOW while (!(VIC.ctrl1 & 0x80)) {};
#define WAIT_WHILE_RASTERLINE_HIGH while (VIC.ctrl1 & 0x80) {};
static const unsigned char sprite0[64] = {
0,0,0,0,0,0,63,255,252,0,0,4,0,0,4,0,0,4,
0,0,4,0,0,4,0,0,4,0,0,4,0,0,4,0,0,4,0,0,4,
0,0,4,0,0,4,0,0,4,0,0,4,0,0,4,0,0,4,63,255,
252,0,0,0,1
};
int main (void){
char *pcAddr;
char *sprite0_ptr;
signed char richtung_x = 0;
signed char richtung_y = 0;
char fire=0;
int x=150,hi_x=0;
char y=100;
char joy,col;
int n;
sprite0_ptr=0x07F8;
pcAddr = 0x0e00;
// bordercolor (4);
// bgcolor (7);
// textcolor (5);
// cursor (0);
clrscr ();
for (n=0; n < 63; n++)
{
*pcAddr = sprite0[n];
pcAddr++;
}
*sprite0_ptr = sprite0_data / 64;
VIC.spr_ena = 1;
VIC.spr0_color = 7;
fire=0;
WAIT_WHILE_RASTERLINE_LOW
WAIT_WHILE_RASTERLINE_LOW;
cputcxy(20,12,65);
while (!fire) {
joy=PEEK(JOY2) & 0x1f;
richtung_x=0;
richtung_y=0;
if (!(joy & JOYFIRE)) fire = 1;
if (!(joy & JOYLEFT)) richtung_x = -1;
if (!(joy & JOYRIGHT)) richtung_x = 1;
if (!(joy & JOYUP)) richtung_y = -1;
if (!(joy & JOYDOWN)) richtung_y = 1;
x += richtung_x;
y += richtung_y;
if (x < 0){
x=0;
}
if (x > 370){
x=370;
}
if (y < 1){
y=1;
}
if (y > 254){
y=254;
}
hi_x=x/255;
WAIT_WHILE_RASTERLINE_LOW;
WAIT_WHILE_RASTERLINE_HIGH;
VIC.spr_hi_x=hi_x;
VIC.spr0_x = x;
VIC.spr0_y = y;
if (VIC.spr_bg_coll==1){
col=1;
}
if (col ==1 & richtung_x==-1){
x=x+5;
}
if (col ==1 & richtung_x==1){
x=x-5;
}
if (col ==1 & richtung_y==-1){
y=y+5;
}
if (col ==1 & richtung_y==1){
y=y-5;
}
col=0;
}
return EXIT_SUCCESS;
}
Alles anzeigen