+SpiceWare Posted September 9, 2011 Share Posted September 9, 2011 I've been working on Frantic, an updated version of Berzerk/Frenzy, for the 2600. It's using the Harmony's ARM processor for the game logic and a slick display kernel that lets me multiplex the Atari's 2 players (sprites) quite effectively to draw all the objects on screen with minimal flicker. I'm now in the process of planning out the Frenzy variation, which has special rooms* every so often. To show the special objects I'm planning to use a 2x or 4x player (I've already reviewed the kernel and while I don't have time to resize of Player 0, I do have time for Player 1). Due to the flicker routines, I have to use software driven collision detection as 2 colliding objects might never be drawn on the same video frame. As such, I'll need to double up a 2x player's bit pattern so that the bits 76543210 become 7766554433221100. For example, if 1 line of the sprite looks like this: _X__X_X_ I need to make it look like this: __XX____XX__XX__ I can do this using a loop and shifting bits, but thought somebody might know a way to do it better. int DoubleBits(unsigned char bits) { int i; int mask; int result; mask = 0x80; result = 0; for(i=0;i<8;i++) { result = (result << 2) + ((bits & mask) ? 3 : 0); mask >>= 1; } return result; } To make that a QuadBits function I'd just change 1 line: result = (result << 4) + ((bits & mask) ? 15 : 0); * This video shows 3 of them, though it's stretched widescreen for some reason: 3:15 Big Otto 5:17 Power Plant 8:01 Central Computer http://www.youtube.com/watch?v=irxvhNdbeoE It's missing the Robot Factory. This video shows the ColecoVision version of Frenzy: 1:18 Big Otto 2:00 Power Plant 3:18 Central Computer 4:01 Robot Factory Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted September 10, 2011 Share Posted September 10, 2011 Can you show the compiled code? Are you targeting THUMB or ARM? In either case, unrolling the loop and using assembly language will be your best option. Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted September 10, 2011 Author Share Posted September 10, 2011 I've decided a better/faster way will be to use a 16 byte table and double up each nybble using a table lookup. Fastest would use a 512 byte table, but that'll take a lot more space than I'd like. Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted September 11, 2011 Author Share Posted September 11, 2011 new routine: const unsigned char double_nybble[] = { 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F, 0xC0, 0xC3, 0xCC, 0xCF, 0xF0, 0xF3, 0xFC, 0xFF}; int DoubleBits(int bits) { return (double_nybble[(bits & 0xf0) >> 4] << + double_nybble[bits & 0x0f]; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.