I've modified three include files: 2600basic.h, std_kernel.asm, and std_overscan.asm.
Note that I've modified the 0.99c2 patch versions (the ones I posted for Superchip bankswitching), so don't apply this patch to anything except 0.99c2!
If anyone wants the modifications for another version, just let me know which version you're using, and I'll post the modifications for that version as well.
Basically, you add the following statement anywhere in your program to tell bB that you want to use the "userscore" option:
dim userscore = yIt doesn't matter what you dim userscore to, the important thing is that you dim it to something so bB will compile your program with the userscore modifications.
What this does is let you define up to 256 different 8x8 sprite objects that you can display in place of the usual score display. (You can actually define more than one set of 256 objects if you want, such as 512 objects in two sets of 256 objects, as long as you manage everything appropriately in your program, but I'd rather not get into that right now, since it's probably going to be difficult enough for anyone to use 256 objects!)
For example, you can define six sprite objects that spell out the name of your game, as long as you can fit it into a 48-pixel-wide image. In my demo, I do this to spell "Reventure!" in the score.
You can also define various "inventory" objects that can be selectively displayed in the score. For example, if you define 16 inventory objects, you can display any of them as a "score digit"-- i.e., up to six selected objects. In my demo, I do this to display a key, a dagger, and a sword. Of course, you'll also want to define a "blank" object for any empty inventory slots.
If you want, you can define each object twice-- once with "normal" graphics, and then a second time with "inverse" graphics-- so that you can display each object as either a "highlighted" ("selected") or "unhighlighted" ("deselected") inventory item, as long as you manage the logic for moving the inventory "cursor" and displaying the correct version of each object (i.e., normal or inverse). In my demo, I do this to move a cursor left and right in the inventory strip. Be warned, though-- the logic for moving the cursor is pretty strange, due to the way bB handles the scorepointers.
Finally, you can switch between the normal bB score display and your custom userscore display, without losing the values for either one! For example, you can display a game title in the score on your startup screen, then switch over to the normal numeric score display once the game begins. Or you can display the normal score display in your game, then temporarily switch to some kind of text message or other userscore display, and then switch back to the numeric score, without losing the value of the numeric score. Performing math operations on the numeric score doesn't affect the userscore display, so you can increment or decrement the numeric score whether or not you're actually displaying the numeric score, then switch to the numeric score whenever desired to display the new score value. In my demo, I set the score to 123456, then let you switch between the title and the numeric score, or between the inventory strip and the numeric score, using the joystick (press up to see the title or inventory strip, and press down to see the numeric score). The demo starts up with the title, and you press the fire button to go to the inventory strip. If you want to go back to the title after you've switched to the inventory strip, you'll need to press reset.
This modification is achieved by using two of bB's "available" variables-- aux2 and aux3. These are redefined to be userscore_page and userscore_flag, respectively.
The userscore_page variable is used to point bB to the page where the score's sprite graphics are located. Normally, bB sets the hi-byte of the score pointers to the page where the default score graphics are located. But if you specify the userscore option (with "dim userscore = y"), you can use userscore_page to point bB to the page where you've defined your custom sprite graphics. If you happen to know what the page number is, then you can say "userscore_page = xxx", where "xxx" is the decimal or hex value of the page number. However, since the page number of your userscore graphics could change as you add code to your program, it's actually easier to do the following:
rem * set userscore_page asm LDA #>my_userscore_graphics STA userscore_page endIn this example, "my_userscore_graphics" is simply the name of the label you're using to mark the beginning of the userscore graphics data area. Yes, this example uses inline assembly (and there's a lot of other inline assembly code snippets in my demo), but you shouldn't let that intimidate you.
The userscore_flag variable is used to switch the userscore display on or off, so you can switch back and forth between the userscore display or the numeric score display. If you want to turn on the userscore display, just say "userscore_flag = 1" (or any other non-zero value between 1 and 255). Likewise, if you want to turn off the userscore display and show bB's normal numeric score, just say "userscore_flag = 0". When userscore_flag is set to 0, bB uses the page number for the default score graphics digits, and updates the score pointers during overscan based on the current value of the score. But when userscore_flag is set to any value between 1 and 255, bB uses the page number that's in the userscore_page variable, and bypasses the overscan routine where the score pointers get updated (so your userscore display won't get destroyed). If you've previously set userscore_flag to 1 to display the userscore graphics, you can change it to 0 and the numeric score will be restored automatically. However, if you change userscore_flag from 0 to 1, you'll need to reload the values of your userscore sprites (or "item numbers") back into the scorepointers before you call drawscreen again, because bB can't load them back automatically for you.
Note that since all of the score graphics data must reside on the same page, your userscore sprite data must fit within 256 bytes, and must not cross a page boundary. If you're defining only a few items (e.g., six sprite shapes for a title display"), you might not have to worry about that if your userscore graphics just happen to fit within a page without extending into another page. But to make sure you don't have a problem with page boundaries, the best thing to do is to include an "align 256" statement just before the beginning of your userscore graphics data, as follows:
asm align 256 my_userscore_graphics ; insert up to 256 bytes for your userscore graphics data here, 8 bytes per object BYTE %00111100 BYTE %01100110 BYTE %11011011 BYTE %11111111 BYTE %11010111 BYTE %11010111 BYTE %01111110 BYTE %00111100 ; etc. endNote that the "align 256" statement must be coded as an inline assembly command. Also, it's best to define the userscore graphics data with inline assembly, rather than with bB's data command, since bB's data command has to insert code for telling bB to skip over the data. However, if you're going to define less than 256 bytes of data for your userscore graphics, then it's okay to use bB's data statement, as follows:
asm align 256 end rem * insert up to 256 bytes for your userscore graphics data here, 8 bytes per object data my_userscore_graphics %00111100 %01100110 %11011011 %11111111 %11010111 %11010111 %01111110 %00111100 endSince your userscore graphics must fit on one page (or in one block of 256 bytes), that means you can define up to 32 sprite shapes on each page, and can select from only 32 sprite shapes at a time. Thus, even though you can have up to 256 sprites or objects (because each "userscore digit" or item number can be a value from 0 to 255), you can't choose from all 256 items at once. Instead, you can define up to 8 pages of userscore graphics shapes, and display any of the 32 shapes on a page at once. For example, you can have one page of 32 items for your game title and brief text messages (e.g., "Game Over" or "You Won!"), and another page of 32 items for inventory objects, etc. When you want to display objects from a particular page, you must set the userscore_page variable to the desired page number.
I've incorporated the modifications so that your bB programs will compile as normal if you don't use the userscore option, with one small exception-- I tweaked the positioning of the score display so that it lines up in the center of the screen, which adds a few more bytes to the std_kernel.asm code. Normally, bB's score display is positioned a little bit to the right of center, which has always bothered me a little bit, although it isn't very noticeable unless you've drawn a playfield, in which case you can see that the score is a little off-center. If you use this 0.99c3 patch, the score will now be centered.
If anyone has questions about using this modification in a program, just post them and I'll try to help as much as possible. Aside from using the score to display a game title or an inventory strip, another idea might be to display up to six "lives remaining" icons. However, you can't display the numeric score and the "lives remaining" at the same time.
MR
Attached Files
Edited by SeaGtGruff, Sun Sep 17, 2006 7:03 PM.
















