+SpiceWare Posted July 4, 2020 Share Posted July 4, 2020 After a long break, I'm finally getting back into 2600 development. Been working on Part 9 - Arena. It shows off how to use the incremental data streams as well as a jump data stream for program flow control. You may have noticed the playfield data is using 5 bytes per row instead of the usual 6. I'm showing how to convert that to the 6 bytes needed for the playfield registers. I used a slightly more advanced version of this in Stay Frosty 2, which allowed for scrolling levels of arbitrary widths. void PrepArenaBuffers() { // The 40 bits for each row of arena data are stored in 5 bytes arranged like this: // byte 0 byte 1 byte 2 byte 3 byte 4 // 33333333 33222222 22221111 11111100 00000000 // 98765432 10987654 32109876 54321098 76543210 // // They need to be converted to this arrangement for the playfield datastreams: // LEFT RIGHT // PF0 PF1 PF2 PF0 PF1 PF2 // 3333---- 33333322 22222222 1111---- 11111100 00000000 // 6789---- 54321098 01234567 6789---- 54321098 01234567 int r; unsigned char *arena = ROM + arena_graphics[mm_arena]; unsigned char *arena_pf0_left = RAM + _BUF_PF0_LEFT; unsigned char *arena_pf1_left = RAM + _BUF_PF1_LEFT; unsigned char *arena_pf2_left = RAM + _BUF_PF2_LEFT; unsigned char *arena_pf0_right = RAM + _BUF_PF0_RIGHT; unsigned char *arena_pf1_right = RAM + _BUF_PF1_RIGHT; unsigned char *arena_pf2_right = RAM + _BUF_PF2_RIGHT; for(r=0; r<arena_heights[mm_arena]; r++) { arena_pf0_left[r] = BitReversal(arena[r*5 + 0]) << 4; arena_pf1_left[r] = (arena[r*5 + 0] << 4) + (arena[r*5 + 1] >> 4); arena_pf2_left[r] = BitReversal((arena[r*5 + 1] << 4) + (arena[r*5 + 2] >> 4)); arena_pf0_right[r] = BitReversal(arena[r*5 + 2]); arena_pf1_right[r] = arena[r*5 + 3]; arena_pf2_right[r] = BitReversal(arena[r*5 + 4]); } } 2 1 Link to comment Share on other sites More sharing options...
+SpiceWare Posted July 10, 2020 Author Share Posted July 10, 2020 Program logic for the next update is finished. I'm now doing a review of the code to revise the comments, such as this: Mode: ds 1 ; $00 = splash, $01 = menu, $80 = game became this: Mode: ds 1 ; $00 = splash, $01 = menu, $80 = game ; these values allow for easy testing of Mode: ; LDA Mode ; BMI GAME_ROUTINE ; BNE MENU_ROUTINE ; BEQ SPLASH_routine and revise variable names such as: _ARENA_HEIGHT = 182 became this: _ARENA_SCANLINES = 180 ; number of scanlines for the arena because the original name could easily be confused with the new heights table for the arenas: _ARENA_HEIGHTS: .byte Arena1_Height .byte Arena2_Height .byte Arena3_Height .byte Arena4_Height The 6507 review is finished, and am about half way done with the C review. I hope to get the next entry posted this weekend. Link to comment Share on other sites More sharing options...
Recommended Posts