Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user gut10 ! (Registered 2020-01-28) You are not logged in 
CSDb User Forums


Forums > C64 Coding > C-64 coding cargo cults
2020-01-14 13:33
Krill

Registered: Apr 2002
Posts: 1343
C-64 coding cargo cults

The most-discussed coding cargo cult on the C-64 is probably SEI/CLI around interrupt setup code.

Here's another one: acknowledging VIC raster interrupts.

According to the datasheet http://archive.6502.org/datasheets/mos_6567_vic_ii_preliminary... an active VIC interrupt is acknowledged by writing a "1" to the corresponding bit in $d019.

The usual way to achieve this seems to be "DEC $D019" and to a lesser extent other read-modify-write instructions, saving a few bytes and/or cycles compared to "LDA $D019 : STA $D019" or "LDA #$xF : STA $D019".
This works because RMW instructions on 6502/6510 read a value (here, the pending interrupts) and write the same value again (clearing the interrupt latches) before writing the modified value.
This is also why this technique does not work on SuperCPU's 65816 in native mode, as its RMW instructions lack the dummy-write of the unmodified value.

Now, the cargo cult bit is this: For raster interrupts, it suffices to write any value with bit 0 set (likewise for other VIC interrupts). Clearing all VIC interrupts can be achieved by writing any value with bits 0..3 set.

So, you can save 2 cycles by simply recycling any register value that happens to have bit 0 set, writing that one to $d019 to acknowledge a VIC raster interrupt.

Please post other coding cargo cults here. =)
 
... 29 posts hidden. Click here to view all posts....
 
2020-01-16 05:57
oziphantom

Registered: Oct 2014
Posts: 361
Quoting Golara
What are you talking about ? The 64 and 65 cycle NTSC machines ?


Yes
2020-01-16 06:30
ChristopherJam

Registered: Aug 2004
Posts: 1004
While most code doesn't specifically require an initial SP of $ff, it's reasonably common to use some of stack space for data (*cough icc*), in which case you at least need to know *something* about the value you initialise it to.

Of course, that could often just as easily be $00 as $ff, or even some arbitrary value in the middle just so long as you know which half a dozen bytes your JSRs and IRQs will be trampling.
2020-01-16 10:13
Golara

Registered: Jan 2018
Posts: 180
Quote: Quoting Golara
What are you talking about ? The 64 and 65 cycle NTSC machines ?


Yes


Is there any story behind it ? Is the first VIC problematic for some screens to display or something ? I knew there are 2 VICs in NTSC but never knew the reason
2020-01-16 11:04
oziphantom

Registered: Oct 2014
Posts: 361
Al stuffed up, counted the wrong number of cycles. The first C64s where thrown out the door.. then he noticed and hence fixed it so it worked properly ;) It was mentioned in one of the interview I'm pretty sure probably the one he did with Bob.
2020-01-16 13:34
Krill

Registered: Apr 2002
Posts: 1343
The problems of 64-cycle per line NTSC VIC-IIs and why 64 cycles happened in the first place are explained here https://spectrum.ieee.org/ns/pdfs/commodore64_mar1985.pdf on page 54 of IEEE Spectrum, March 1985 (page 7 in the PDF).

And yet, 64-cycle NTSC C-64s aren't that rare, as the fixed VIC-II revision was rolled out only about 5 months into production.
2020-01-16 18:20
Golara

Registered: Jan 2018
Posts: 180
Quote: The problems of 64-cycle per line NTSC VIC-IIs and why 64 cycles happened in the first place are explained here https://spectrum.ieee.org/ns/pdfs/commodore64_mar1985.pdf on page 54 of IEEE Spectrum, March 1985 (page 7 in the PDF).

And yet, 64-cycle NTSC C-64s aren't that rare, as the fixed VIC-II revision was rolled out only about 5 months into production.


Cool, didn't know that. Only 5 months and you say it isn't that rare, interesting. The computer itself is not that rare maybe, but how many people use it today and have that as their only (or main) c64 ? Cuz I understand having that as a collector item, but not for "daily" use, as it also has that flicker
2020-01-16 19:03
Krill

Registered: Apr 2002
Posts: 1343
Quoting Golara
Cool, didn't know that. Only 5 months and you say it isn't that rare, interesting.
5 months worth of production is probably a lot of machines to be sold.

Quoting Golara
The computer itself is not that rare maybe, but how many people use it today and have that as their only (or main) c64 ? Cuz I understand having that as a collector item, but not for "daily" use
It's not worth supporting in new productions, if that's what you mean.

Quoting Golara
as it also has that flicker
What do you mean? The "sparkle" issue? That isn't related to VIC-II but the chargen ROM.
2020-01-16 19:17
Golara

Registered: Jan 2018
Posts: 180
Quote: Quoting Golara
Cool, didn't know that. Only 5 months and you say it isn't that rare, interesting.
5 months worth of production is probably a lot of machines to be sold.

Quoting Golara
The computer itself is not that rare maybe, but how many people use it today and have that as their only (or main) c64 ? Cuz I understand having that as a collector item, but not for "daily" use
It's not worth supporting in new productions, if that's what you mean.

Quoting Golara
as it also has that flicker
What do you mean? The "sparkle" issue? That isn't related to VIC-II but the chargen ROM.


Yeah but both issues were fixed about the same time didn't it ?
2020-01-17 00:37
Krill

Registered: Apr 2002
Posts: 1343
Quoting Golara
Yeah but both issues were fixed about the same time didn't it ?
"About" is pretty relative.

Sparkle: "The problem was fixed before Charpentier left the company in September 1982. [...] Only the first few hundred thousand units shipped with the defect."

64 cycles: "The error, which was corrected sometime after Charpentier left the company [...]"

So, there seem to be quite a few 64-cycles C64s without the sparkle bug. At least i've never noticed that problem on my Canadian model. =)
2020-01-17 10:38
oziphantom

Registered: Oct 2014
Posts: 361
surely this is limited to Silver Label NTSC models. Couldn't be more than 500,000 of them. 1/36th of the units.
Previous - 1 | 2 | 3 | 4 - 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
Flex/Artline Designs
Jasmin68k
hedning/G★P
Broti/DT/KRN
MagerValp/G★P
Pitcher/Fairlight
Zirias/Excess
AMB/Level 64
Acidchild/Padua
Mythus/Delysid
Walt/Bonzai
psych858o/MSL/Elysiu..
tyron
Ghost/Excess
Snabel
Viti/Hokuto Force
Guests online: 61
Top Demos
1 Uncensored  (9.7)
2 Coma Light 13  (9.7)
3 Edge of Disgrace  (9.7)
4 Unboxed  (9.7)
5 Comaland 100%  (9.6)
6 Lunatico  (9.6)
7 The Shores of Reflec..  (9.5)
8 Rivalry  (9.5)
9 X Marks the Spot  (9.5)
10 C=Bit 18  (9.5)
Top onefile Demos
1 Tribute to Ben - Las..  (9.8)
2 Gumbo Revised  (9.6)
3 Crystal Gazer  (9.6)
4 Smile to the Sky  (9.5)
5 Dawnfall V1.1  (9.5)
6 Daah, Those Acid Pil..  (9.5)
7 Instinct  (9.5)
8 Innervasion  (9.5)
9 Merry Krampus  (9.5)
10 Pandemoniac Part 5 o..  (9.5)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Fossil  (9.4)
4 PriorArt  (9.4)
5 Censor Design  (9.4)
Top Diskmag Editors
1 hedning  (9.8)
2 Jazzcat  (9.5)
3 Newscopy  (9.3)
4 Remix  (9.2)
5 A Life in Hell  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2020
Page generated in: 0.036 sec.