|
Post by bjonte on Oct 11, 2019 20:04:54 GMT
I banged my head against my keyboard input code, that just didn't work properly, until I figured out that the code was too quick for 2 MHz. This is a pretty fat gotcha that the emulators aren't emulating yet so it only breaks on the real hardware. You basically can't write to $dc00 and read from $dc01 the next instruction. You have to insert a nop inbetween. This is my test program that proves it.
include "../core/6502/macros.asm" include "../core/6502/devices/c128.asm"
section code, "main", $1c01, $d000 { relocate_basic_line(2019, .start)
.start: sei cld lda #%11111111 sta XSCAN lda #%11111111 // output sta CIDDRA lda #%00000000 // input sta CIDDRB
ldx #7 lda #0 { sta COLORRAM,x dex bpl @loop }
{ // wait for border { lda SCROLY bmi @loop lda RASTER bne @loop } c128_go2mhz()
repeat 8 { lda #%11111111 ^ (1 << @i) sta CIAPRA lda CIAPRB sta $0400 + @i }
c128_go1mhz() clc bcc @loop } }
I'm attaching a test program without the nop and one with. I'd be grateful if you people with real machines could test the one with the nop and tell me if it works for you. When pressing the R key, only one character on the top left should change. In the program without the nop, two are changed as the keyboard read fails and registers two different keys instead of one.
|
|
|
Post by bjonte on Oct 11, 2019 20:18:43 GMT
After an additional test it seems to be enough with one cycle extra between write and read to make the read work for me on a PAL machine. I haven’t tested NTSC yet.
|
|