News for hackers. Stuff that matters.
Re:Writing a game from first principles in 65c02 – Part One by pvg on Saturday May 29, 2021 @05:44PM (#27328465)
It's not linear but it's modulo-ish and lookup-table-able. The colour is definitely mildly weird too but again, I think part of it is that it looks so unfamiliar in hindsight. I don't think these things that had much of an impact on high-performance code compared to 'it's just a blob of memory and every single thing has to be done by the anemic CPU'.
Re:Writing a game from first principles in 65c02 – Part One by dhosek on Saturday May 29, 2021 @11:55PM (#27330463)
When you're writing in 6502 assembler, the weird layout actually turns out to be easier to program against then the Commodore approach where they arranged the lines consecutively. It turns out that doing a multiply by 40 operation is a bit tricky in that context. I am pretty sure that I could still write 6502 assembly to do 40-column graphics access on the Apple ][ if I had to. The 80-column mode stuff I'm less confident about since I don't remember if the memory banking was left-half/right-half or odd/even.
Re:Writing a game from first principles in 65c02 – Part One by ddingus on Sunday May 30, 2021 @10:40AM (#27333554)
Odd even
Re:Writing a game from first principles in 65c02 – Part One by wiz21c on Sunday May 30, 2021 @04:04AM (#27331499)
Having recently coded 2 demos on the Apple2 [*], I can assure you that the "modulosih-lookup-table2" is a nightmare to work with. Plenty of unwanted color artifact + the modulo and table lookup cost a hell of a lot of CPU cycles (the Apple has no dedicated graphics chip)...

[*] https://www.youtube.com/watch?v=Dlmrd0howLw

Re:Writing a game from first principles in 65c02 – Part One by pvg on Sunday May 30, 2021 @06:55AM (#27332273)
Very cool. But it's also a good answer to the GP and some of the downthread colour questions - if push comes to shove, you can just ignore the colour. You didn't link it so I'll take the liberty: github repo is at

https://github.com/wiz21b/lowtech

Re:Writing a game from first principles in 65c02 – Part One by ddingus on Saturday May 29, 2021 @07:08PM (#27329023)
The 7 pixel per byte was the hard part.

Color by bit position repeated every 2 bytes, or 14 pixels.

Re:Writing a game from first principles in 65c02 – Part One by pvg on Saturday May 29, 2021 @11:47PM (#27330440)
Again, I don't think that was really the limiting factor to performance - it can be addressed by pre-computation and other trickery. It's worth remembering it took until the beginning of the 90s for something like a mario-style side scrolling game to be possible on a PC, with a lot of clever hacking, a much more powerful CPU and slightly more programmer-accessible (but still largely dumb framebuffer) video hardware.
Re:Writing a game from first principles in 65c02 – Part One by ddingus on Sunday May 30, 2021 @03:00AM (#27331200)
To me, it boils down to RAM.

One can choose to store the data in weird ways that map to the screen, or use table lookups. From there, unrolled code can go damn fast too, and in all those scenarios, RAM is used to cope with goofy addressing.

Then comes 7 pixels per byte!

On the plus side, doing that, plus the high bit shifting pixels a little to provide a basic color attribute bit, meant getting a 6 color display instead of a 4 color one.

6 colors is enough to do basically anything. 4 is not quite enough.

But, that also means having to either shift data prior to blitting it to the screen (slower), or preshifting (faster), and more preshifted data copies are needed because the color by bit position repeats every two bytes, not every byte like pretty much all the other 1bpp + artifact, or 2bpp systems needed.

If one has the RAM, fact is the Apple did not have screen DMA wait states slowing the CPU down. That meant getting the best of 1Mhz.

It also made the system easy to accelerate too.

A 2 to 4Mhz Apple performs very well on software sprites.

But even the stock machine could deliver quite a bit more than one might expect, given things could fit into RAM.

4Mhz can deliver a side scroller on par, BTW. But, that would still be a RAM challenge to hold the diversity of images seen in something like Keen.