3 ms·
random question - with a screen width of 320, how do you deal with screen coordinates in 8-bit variables?
by blt 12y ago
random question - with a screen width of 320, how do you deal with screen coordinates in 8-bit variables?
- pkaye 12y agoYou use 16-bit variables.
- blt 12y agoSo, 2 registers and 16-bit math in software? Was this common, or did games find a way around it?
- daeken 12y agoYes, it was common. Also common was to have entities in your game exist on a grid, and multiply/shift those positions to get screen coordinates, when they were needed.
- ddingus 12y agoSure. Toss up some side bar / status / score thing, and run the game in 8 bit coordinates. Or, double up on movement, make the game 160 pixels, and just run that way. The multi-color mode on C64 is 160 pixels, and that got used for a ton of games. Finally, mixed screen setups. Sprites, high resolution (320) and multi-color (160) all were used concurrently. The coordinates for those could easily be 8 bits, and just operate in regions of the screen.
- pkaye 12y agoWell the 6502 didn't have many registers but the CPU and SRAM were of similar speed back then so most of the temporary values were stored in SRAM. Not too long ago I did firmware on an 8-bit processor using the C language. It would support 32/16/8-bit variables. You just have to choose the smallest one possible to be most efficient.
- xacto75 12y agoThe C64 had one byte at $D010 -- 8 bits, one for each sprite -- that, when set, would add an offset to that sprite's X position, moving it beyond the 256 limit. This would allow the contents of each sprite's X position register to reset at 0, staying within the 8-bit limit.