More meetings than usual

Wednesday, February 27, 2019

Some meetings were quite late (US-bound), and I'm already overly tired, so my attention span was just not there.

Not much that I can put on this blog...

Systems update

Time to update my test systems to follow up on a request that Karen made about testing SMT configuration.

QEMU kconfig branch

Checked with Paolo if github was the right place to look for his kconfig branch.

He said it was, and confirmed that he does not want make config targets. "The documentation explains why. :)" RTFM, Christophe. Will check.

Hatari and Alpha-Waves

Installed Hatari, an Atari ST emulator, with the intent to check how well Alpha Waves behaved on it. It's impressive! Running at 4x the CPU speed (32MHz) also makes the game perfectly smooth. It was a blast. Had to hack my own program in order to disable the copy protection. Long time I had not read 68K assembly language, nor patched a binary using Emacs' hexl-mode.

Then I tried two-player mode, and ran into an Hatari bug, where it does not correctly display the colors at the bottom of the screen.

The code that deal with color palette changes is quite smart, actually, counting CPU cycles (and taking into account overclocking) in order to reproduce what an actual Atari ST would display. Only it does not work in the case of Alpha Waves, because apparently there is some hypothesis being made on how many colors can be changed on a single line, and when they are changed.

Alpha Waves changed all 16 colors in the same scanline, using the 68K movem instruction. It did that in an interrupt handler (hey, that was a machine running always in supervisor mode, no MMU!). Changing all 16 colors in the middle of a line seems to confuse the code in Spec512_EndScanLine that sees no leftover colors to update, when there are.

Here is the update of the palette at the top (line 0). You can see that it updates all 16 color palette registers (look for idx=0..idx=15).

spec store col line 0 cyc=148 col=652 idx=0 video_cyc=584 584@0 pc=1d030 instr_cyc=8

write col addr=ff8240 col=652 video_cyc_w=592 line_cyc_w=148 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 1 HorPos 148 spec store col line 0 cyc=152 col=276 idx=1 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff8242 col=276 video_cyc_w=596 line_cyc_w=149 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 2 HorPos 148 spec store col line 0 cyc=156 col=731 idx=2 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff8244 col=731 video_cyc_w=600 line_cyc_w=150 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 3 HorPos 148 spec store col line 0 cyc=160 col=110 idx=3 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff8246 col=110 video_cyc_w=604 line_cyc_w=151 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 4 HorPos 152 spec store col line 0 cyc=164 col=752 idx=4 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff8248 col=752 video_cyc_w=608 line_cyc_w=152 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 5 HorPos 152 spec store col line 0 cyc=168 col=652 idx=5 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff824a col=652 video_cyc_w=612 line_cyc_w=153 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 6 HorPos 152 spec store col line 0 cyc=172 col=641 idx=6 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff824c col=641 video_cyc_w=616 line_cyc_w=154 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 7 HorPos 152 spec store col line 0 cyc=176 col=540 idx=7 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff824e col=540 video_cyc_w=620 line_cyc_w=155 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 8 HorPos 156 spec store col line 0 cyc=180 col=064 idx=8 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff8250 col=64 video_cyc_w=624 line_cyc_w=156 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 9 HorPos 156 spec store col line 0 cyc=184 col=732 idx=9 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff8252 col=732 video_cyc_w=628 line_cyc_w=157 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 10 HorPos 156 spec store col line 0 cyc=188 col=770 idx=10 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff8254 col=770 video_cyc_w=632 line_cyc_w=158 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 11 HorPos 156 spec store col line 0 cyc=192 col=525 idx=11 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff8256 col=525 video_cyc_w=636 line_cyc_w=159 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 12 HorPos 160 spec store col line 0 cyc=196 col=137 idx=12 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff8258 col=137 video_cyc_w=640 line_cyc_w=160 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 13 HorPos 160 spec store col line 0 cyc=200 col=414 idx=13 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff825a col=414 video_cyc_w=644 line_cyc_w=161 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 14 HorPos 160 spec store col line 0 cyc=204 col=541 idx=14 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff825c col=541 video_cyc_w=648 line_cyc_w=162 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8 DDD: Scanline 0 nCyclePalettes 15 HorPos 160 spec store col line 0 cyc=208 col=551 idx=15 video_cyc=584 584@0 pc=1d030 instr_cyc=8 write col addr=ff825e col=551 video_cyc_w=652 line_cyc_w=163 @ nHBL=0/video_hbl_w=0 pc=1d030 instr_cyc=8

The same happen line 133 with the second palette:

spec store col line 133 cyc=468 col=115 idx=0 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8

write col addr=ff8240 col=115 video_cyc_w=272136 line_cyc_w=470 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 1 HorPos 468 spec store col line 133 cyc=472 col=067 idx=1 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff8242 col=67 video_cyc_w=272140 line_cyc_w=471 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 2 HorPos 472 spec store col line 133 cyc=476 col=722 idx=2 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff8244 col=722 video_cyc_w=272144 line_cyc_w=472 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 3 HorPos 472 spec store col line 133 cyc=480 col=101 idx=3 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff8246 col=101 video_cyc_w=272148 line_cyc_w=473 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 4 HorPos 472 spec store col line 133 cyc=484 col=047 idx=4 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff8248 col=47 video_cyc_w=272152 line_cyc_w=474 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 5 HorPos 472 spec store col line 133 cyc=488 col=437 idx=5 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff824a col=437 video_cyc_w=272156 line_cyc_w=475 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 6 HorPos 476 spec store col line 133 cyc=492 col=305 idx=6 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff824c col=305 video_cyc_w=272160 line_cyc_w=476 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 7 HorPos 476 spec store col line 133 cyc=496 col=416 idx=7 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff824e col=416 video_cyc_w=272164 line_cyc_w=477 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 8 HorPos 476 spec store col line 133 cyc=500 col=137 idx=8 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff8250 col=137 video_cyc_w=272168 line_cyc_w=478 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 9 HorPos 476 spec store col line 133 cyc=504 col=754 idx=9 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff8252 col=754 video_cyc_w=272172 line_cyc_w=479 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 10 HorPos 480 spec store col line 133 cyc=508 col=067 idx=10 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff8254 col=67 video_cyc_w=272176 line_cyc_w=480 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 11 HorPos 480 spec store col line 133 cyc=512 col=747 idx=11 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff8256 col=747 video_cyc_w=272180 line_cyc_w=481 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 12 HorPos 480 spec store col line 133 cyc=516 col=625 idx=12 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff8258 col=625 video_cyc_w=272184 line_cyc_w=482 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 13 HorPos 480 spec store col line 133 cyc=520 col=365 idx=13 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff825a col=365 video_cyc_w=272188 line_cyc_w=483 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 14 HorPos 484 spec store col line 133 cyc=524 col=754 idx=14 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff825c col=754 video_cyc_w=272192 line_cyc_w=484 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8 DDD: Scanline 133 nCyclePalettes 15 HorPos 484 spec store col line 133 cyc=528 col=026 idx=15 video_cyc=272128 1872@133 pc=1cffc instr_cyc=8 write col addr=ff825e col=26 video_cyc_w=272196 line_cyc_w=485 @ nHBL=133/video_hbl_w=133 pc=1cffc instr_cyc=8

Each color on the Atari ST is coded on 12 bits, 4 for red, green and blue. These were the times So here, we wrote colors as follows: 115 067 722 101 047 437 305 416 137 754 067 747 625 365 754 and 026.

Things go wrong when reconstructing the image for rendering:

Is SPEC512

pDrawFunction=0x101de9f20 ConvertLowRes_640x32Bit_Spec upd spec cyc 148 0 652 << START OF FIRST PALETTE upd spec cyc 152 1 276 upd spec cyc 156 2 731 upd spec cyc 160 3 110 upd spec cyc 164 4 752 upd spec cyc 168 5 652 upd spec cyc 172 6 641 upd spec cyc 176 7 540 upd spec cyc 180 8 64 upd spec cyc 184 9 732 upd spec cyc 188 a 770 upd spec cyc 192 b 525 upd spec cyc 196 c 137 upd spec cyc 200 d 414 upd spec cyc 204 e 541 upd spec cyc 208 f 551 << END OF FIRST PALETTE upd spec cyc 468 0 115 << START OF SECOND PALETTE upd spec cyc 472 1 67 upd spec cyc 476 2 722 upd spec cyc 480 3 101 upd spec cyc 484 4 47 upd spec cyc 488 5 437 upd spec cyc 492 6 305 upd spec cyc 496 7 416 upd spec cyc 500 8 137 upd spec cyc 504 9 754 << WHY STOP AT 9? upd spec cyc 464 0 115 << RESTARTING AT 0? upd spec cyc 468 1 67 upd spec cyc 472 2 722 upd spec cyc 476 3 101 upd spec cyc 480 4 47 upd spec cyc 484 5 437 upd spec cyc 488 6 305 upd spec cyc 492 7 416 upd spec cyc 496 8 137 upd spec cyc 500 9 754 upd spec cyc 504 a 67 << WHY STOP AT A? upd spec cyc 0 0 0 << WHER DOES THIS COME FROM? upd spec cyc 0 0 0 upd spec cyc 0 0 0 upd spec cyc 0 0 0 upd spec cyc 0 0 0

So the bug is in the playback portion, which only updates up to some register and then stops.