Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > (Ab)use of dummy accesses
2020-03-09 17:04
chatGPZ

Registered: Dec 2001
Posts: 11148
(Ab)use of dummy accesses

For the next release of my "No more Secrets" doc i am preparing a chapter related to the dummy access which happen when the CPU performs an internal operation. Once again i am looking for some examples on how to (ab)use it :) I guess everyone knows "inc $d019" - but i am sure there is more than this. And not only with RMW instructions. So if you have anything in your mind - just drop it here!

here are some related notes which i pasted together. feel free to proofread and point out mistakes :)
 
... 55 posts hidden. Click here to view all posts....
 
2020-03-29 19:08
Oswald

Registered: Apr 2002
Posts: 5028
make em 3 cycles wide :)
2020-04-01 20:14
Hoogo

Registered: Jun 2002
Posts: 102
What about the color of the colorram in multicolor FLI?
2020-04-01 21:49
chatGPZ

Registered: Dec 2001
Posts: 11148
what about it?
2020-04-02 09:16
Hoogo

Registered: Jun 2002
Posts: 102
Is it an example for "side effect of fetching next opcode" for your purpose?
2020-04-03 15:43
chatGPZ

Registered: Dec 2001
Posts: 11148
yes and no - this particular case is already described in detail in the pdf ("Blackmail FLI") :)
2020-04-03 16:24
chatGPZ

Registered: Dec 2001
Posts: 11148
Quote: Lovely stuff!!!

” Most 1-Byte instructions will fetch PC+1 after the opcode fetch”

All 1-byte right?


btw, its not all of them .... the various JAM opcodes will stall before that happens. not that it matters :)
2020-04-03 17:13
JackAsser

Registered: Jun 2002
Posts: 1994
Quote: btw, its not all of them .... the various JAM opcodes will stall before that happens. not that it matters :)

Haha wtf! That doesn’t count!! :D
2020-04-05 21:10
CyberBrain
Administrator

Posts: 392
Ok, let me take a stab at abusing the dummy write-cycle of RMW instructions:


$3FFF (ghostbyte) under ROM

As we know, when reading a byte from ROM, the CPU reads from the ROM, but when writing to a byte in the ROM, the write falls through to the RAM beneath it.
So with an RMW instruction you can actually write 2 values to a byte in RAM, 1 cycle apart, where none of the two written values are the value that was already present.
Usually not a useful thing to do, but together with the VIC we could exploit this:

Put the VIC in bank 2 or 3 and enable the KERNAL/BASIC ROM. Then an INC (for example) can write to the ghostbyte twice, 1 cycle apart - and the first write doesn't necessarily have to write what was already there!

Unfortunately what you can write at the first dummy cycle is limited to what is in the ROM at the chosen ghostbyte address (4 possibilities).
What you can write at the 2nd write cycle also depends on that value as well as which RMW-instruction you use (so we have 6 possibilities per ghostbyte address for the second write-cycle).

Let's look at which possibilities of pixels we have:

                               First wcycle    Second wcycle:
                                   |           INC         DEC         ASL         ROL (C=1)   LSR         ROR (C=1)
 - $B7FF in ROM contains $B0 = %10110000.      %10110001   %10101111   %01100000   %01100001   %01011000   %11011000
 - $BFFF in ROM contains $E0 = %11100000.      %11100001   %11011111   %11000000   %11000001   %01110000   %11110000
 - $F7FF in ROM contains $D1 = %11010001.      %11010010   %11010000   %10100010   %10100011   %01101000   %11101000
 - $FFFF in ROM contains $FF = %11111111.      %00000000   %11111110   %11111110   %11111111   %01111111   %11111111
                                                  |
                                                  +----> (*)


The choice marked with (*) ($FFFF and INC) might be useful in practice to create a *single cycle* wide $FF pattern! ($00 -> $FF -> $00)

Just do an INC $FFFF somewhere the ghostbyte is visible. (And init the ghostbyte to $00 in advance)

(This can of course be repeated all the way throughout the border, the x-pos can be changed, can be done multiple times per rasterline, etc etc)

Perhaps one can even be creative and use the other patterns for something too...



Charset/Bitmap

Instead of the ghostbyte, the same could be done for charset/bitmaps (but not sprites or the screen) - maybe there is an application there too.

For example (using precise timing) a charset-byte could could be set to $FF at the exact time it is read by the VIC, using the dummy-write of an INC, and then to $00 immediately after, at the second write-cycle, so that it is $00 next time it is rendered by the VIC (instead of LDA #$FF, STA $xxxx, LDA #$00; STA $xxxx).
When repeating the 7th pixel-line of a text-line using linecrunch, for example, this could make the charset-byte $FF on one raster line and $00 on the next with only one INC $xxxx instruction.

That could of course be repeated again and again, every 2nd line, so that the charset-byte alternates between $00 and $FF every rasterline...
(Of course, this requires that there is a $FF or $00 byte in the ROM at that location - but other values might be nice too)

But I haven't really found a totally perfect use-case for this yet, so not sure if it's useful in practice. Ideas?
2020-04-05 22:16
tlr

Registered: Sep 2003
Posts: 1727
_Very_ cool! We approves.
2020-04-05 22:54
chatGPZ

Registered: Dec 2001
Posts: 11148
YES! keep it coming! :)
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
psenough
Mr. SID
Linus/MSL
Acidchild/Padua
MCM/ONSLAUGHT
Oswald/Resource
iAN CooG/HVSC
Skylab/The Movers
Asphodel
Guests online: 137
Top Demos
1 Next Level  (9.8)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 No Bounds  (9.6)
7 Comaland 100%  (9.6)
8 Uncensored  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 Layers  (9.6)
2 It's More Fun to Com..  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Covert Bitops  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Crest  (9.3)
5 Censor Design  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.061 sec.