There is probably a very simple answer to this but I'm stumped. I'm trying to copy some standard charset chars from b400 to a hires screen. I can print SPACE ok (char 32) but any other char I get garbage.
In the pic above, the circled bit are the results I get from using an ASM routine. It SHOULD look like the main picture (produced using curset + hchar). I've got the right location and the right color but - somehow, the wrong data.
First the C code which sets some variable values and calls the asm code - chasm()
The variable deadtoggle controls wether to print spaces or pieces.
Code: Select all
void deadpile(){
unsigned char tmpchar;
if (playertype == 2){ // ATTACKERS
if ( deadtoggle ) deadattackers++;
deadplayers=deadattackers;
deadcurset=0xa025; // correct location for dead attackers column (works)
tmpchar=0xb400+(41*8); // ")" = char 41 - this does not seem to work
}
if (playertype == 1){ // DEFENDERS
if ( deadtoggle ) deaddefenders++;
deadplayers=deaddefenders;
deadcurset=0xa027; // correct location for dead defenders column (works)
tmpchar=0xb400+(40*8); // "(" = char 40 - this does not seem to work
}
if ( deadplayers ){
for (x=0;x<deadplayers;x++){
deadchar=tmpchar; // copy the value of tmpchar to deadchar (used in asm routine)
if ( deadtoggle == 0 ) deadchar=0xb400+(32*8); // space (works)
chasm(); // print char at given location
deadcurset+=360; // 40*9 (advance a line - Works)
}
}
}
Code: Select all
_chasm
.(
lda _deadcurset+0
sta tmp1+0
lda _deadcurset+1
sta tmp1+1
; print 7 rows of data
ldx #7
loop
ldy #0
; load the value stored at deadchar
lda _deadchar
; print it on the screen
sta (tmp1),y
; now advance to the next byte of the characters bit pattern
jsr _IncDeadChar
; advance to the next row
jsr _Add40
dex
bne loop
rts
.)
; add one to the value of deadchar to get the next byte of the bit pattern
_IncDeadChar
.(
clc
lda _deadchar+0
adc #1
sta _deadchar+0
bcc skip
inc _deadchar+1
skip
rts
.)
Puzzled and delayed
Barnsey