RevEng Posted October 13, 2014 Author Share Posted October 13, 2014 I've got a question about comparing using score0 as a 'points' counter and using IF...THEN statements. I have set up a shop where the player buys something and if he has enough points, the item should disappear, score0 should reduce by 25 and score1 should increase. So I reduced score0 to four digits meaning that if something is 100, it's actually 1. So what about using two digit numbers like 25? For instance... if score0=0025 && boxcollision(xpos,ypos,16,16,orange_x,orange_y,16,16) then orange_x=200:orange_y=200: score0=score0-0025: score1=score1+0015:store_response=1 So far, the code above doesn't work. I'm wondering if I need to use BCD for something like this? Because the score variables are 24-bit variables, using them in an if...then comparison doesn't work correctly. To use them in comparisons, you actually need to look at the constituent bytes like this... dim sc00=score0 : rem ##0000 dim sc01=score0+1 : rem 00##00 dim sc02=score0+2 : rem 0000## if sc02=$25 && boxcollision(xpos,ypos,16,16,orange_x,orange_y,16,16) then orange_x=200:orange_y=200: score0=score0-0025: score1=score1+0015:store_response=1 Let me know how that works out for you. Alright this may be a dumb question, but I've finally got around to sitting down with this, currently just going through the sample code, one thing I don't understand is why in the adventure demo, and multisprite demo is tileset_blanks loaded and referred to as the tilemap rather than tileset_rocks? What role does tileset_blanks play? Not at all a dumb question! When you have a bunch of character images consecutive in memory, you can access them all in the map. Think of them as one big image set, even though you used separate incgraphic statements to bring them all in. tileset_blanks isn't special, except for the fact that it's the first tileset brought in with incgraphic. For the 7800 colors, check out this thread 1 Quote Link to comment Share on other sites More sharing options...
Trebor Posted October 13, 2014 Share Posted October 13, 2014 For the 7800 colors, check out this thread I humbly suggest, the better/updated final work, complete with chart (hex value) references here. If that link is TMI...try here instead. 2 Quote Link to comment Share on other sites More sharing options...
Loktar Posted October 13, 2014 Share Posted October 13, 2014 Because the score variables are 24-bit variables, using them in an if...then comparison doesn't work correctly. To use them in comparisons, you actually need to look at the constituent bytes like this... dim sc00=score0 : rem ##0000 dim sc01=score0+1 : rem 00##00 dim sc02=score0+2 : rem 0000## if sc02=$25 && boxcollision(xpos,ypos,16,16,orange_x,orange_y,16,16) then orange_x=200:orange_y=200: score0=score0-0025: score1=score1+0015:store_response=1 Let me know how that works out for you. Not at all a dumb question! When you have a bunch of character images consecutive in memory, you can access them all in the map. Think of them as one big image set, even though you used separate incgraphic statements to bring them all in. tileset_blanks isn't special, except for the fact that it's the first tileset brought in with incgraphic. For the 7800 colors, check out this thread Ahh that makes total sense, that explains why abc were solid colors thanks! I humbly suggest, the better/updated final work, complete with chart (hex value) references here. If that link is TMI...try here instead. Awesome thanks! Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 13, 2014 Author Share Posted October 13, 2014 Glad to help! Quote Link to comment Share on other sites More sharing options...
+frankodragon Posted October 13, 2014 Share Posted October 13, 2014 Because the score variables are 24-bit variables, using them in an if...then comparison doesn't work correctly. To use them in comparisons, you actually need to look at the constituent bytes like this... dim sc00=score0 : rem ##0000 dim sc01=score0+1 : rem 00##00 dim sc02=score0+2 : rem 0000## if sc02=$25 && boxcollision(xpos,ypos,16,16,orange_x,orange_y,16,16) then orange_x=200:orange_y=200: score0=score0-0025: score1=score1+0015:store_response=1 Let me know how that works out for you. I had to tweak the code but it does work: if sc01=$025 && boxcollision(xpos,ypos,16,16,orange_x,orange_y,16,16) then orange_x=200:orange_y=200: score0=score0-2500: score1=score1+15:store_bought=1 I changed the points counter back to three digits, but had to use 2500 instead of 25, otherwise it only takes 2 off the points score. Quote Link to comment Share on other sites More sharing options...
bigbacon Posted October 16, 2014 Share Posted October 16, 2014 are there any example codes out there to help get one started? Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 16, 2014 Author Share Posted October 16, 2014 Check out the samples directory, which has a few different code examples. Quote Link to comment Share on other sites More sharing options...
+frankodragon Posted October 19, 2014 Share Posted October 19, 2014 It looks like I'll have to expand to 128k. I tried that bankswitch example but I think I still need some help with it. Quote Link to comment Share on other sites More sharing options...
CPUWIZ Posted October 19, 2014 Share Posted October 19, 2014 I suppose what you want is really 144K, so you can have this scenario: $4000-$7FFF (16K code/gfx) $8000-$BFFF (8 banks) $C000-$FFFF (16K code/gfx) Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 19, 2014 Author Share Posted October 19, 2014 I haven't gotten around to adding in 144k yet. Its easy enough in principle, but it's lower on the list. Quote Link to comment Share on other sites More sharing options...
Cybearg Posted October 19, 2014 Share Posted October 19, 2014 (edited) So graphics/playfield data is limited to only certain banks, like in batariBasic? I would have thought that graphics, maps, and music would comprise the bulk of a game's data. On an unrelated note, how difficult would it be to do a compilation cart with 7800basic? Is it just a matter of building a number of games and just keeping their data separated but otherwise programming as normal, or are there some necessarily tricks to get around things like palette data being set that can't be changed in a ROM? On another unrelated note, what's the compression like for graphics/map/music/etc. data in 7800basic? Does it provide some built-in compression, or does that have to be done yourself? I know that you're just discussing 144k, but will higher values like the 512k+ that batariBasic can handle eventually come to 7800basic? Edited October 19, 2014 by Cybearg Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 19, 2014 Author Share Posted October 19, 2014 The graphics can go in any bank. You just need to call "drawscreen" in the bank with graphics you want to display. The easiest way to do a compilation cart would be to code the games to coexist. Otherwise you'd need custom bankswitch hardware and support added to 7800basic. Also, palette colors can be changed on the fly. There's no built-in compression, since that would require RAM to decompress to, and our limited RAM would put a boundary on the amount of active graphics. 7800basic already supports sizes up to 512k. See "set romsize" in the manual. It just doesn't support formats with an extra perma-bank at $4000, like 144k. Quote Link to comment Share on other sites More sharing options...
Cybearg Posted October 19, 2014 Share Posted October 19, 2014 Ah, that's a relief. Thanks, Rev! Are there any parts set by 7800basic that can't be changed on the fly when developing multiple games on the same cart? In batariBasic, there are quite a few things that can only be set once that significantly affect the games' design, like your kernel. Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 19, 2014 Author Share Posted October 19, 2014 No problem. The hardcoded stuff is in the guide under Program Configuration. Quote Link to comment Share on other sites More sharing options...
+frankodragon Posted October 19, 2014 Share Posted October 19, 2014 Do dim arrays also need to be put into other banks? I get label mismatch errors when compiling in 128K. Quote Link to comment Share on other sites More sharing options...
Cybearg Posted October 20, 2014 Share Posted October 20, 2014 As a small feature request, could 7800basic support inlining .bas files? IntyBasic recently added support for including one .bas file in another, which has allowed me to break sound, music, map, and table data out into separate .bas files for individual editing. It has done wonders for reducing clutter in my main .bas file and it would be great to have that same feature in 7800basic, especially since 7800 games can conceivably be so huge. Also consider this a feature request for batariBasic to add the same functionality. I'd think it would be as simple as checking to see whether an include is a .bas or an .asm file, then including .bas files before compilation and .asm files after compilation but before assembly. Quote Link to comment Share on other sites More sharing options...
+frankodragon Posted October 20, 2014 Share Posted October 20, 2014 So now I have two banks: one for the world map and the other for the dungeon map. I get an "graphics overrun error" in bank #1 which tells me I have to declare another (a 3rd?) bank? Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 20, 2014 Author Share Posted October 20, 2014 Pretty much. The error message means you have too many graphics with "incraphic" in bank1. You'll have to shift some of those to another bank. Just bear in mind when you issue "drawscreen" you can only use graphics in the last bank or the same bank with the "drawscreen" command. Quote Link to comment Share on other sites More sharing options...
CPUWIZ Posted October 20, 2014 Share Posted October 20, 2014 I am curious about why it is not a 10-15 minute thing, to add a fixed bank at $4000. Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 20, 2014 Author Share Posted October 20, 2014 The various banking routines need exceptions to not bank when trying to accessing the second last bank, and to curse at the user when he tries to switch to them. It may be 10 or 15 minutes of coding, and then another 10 or 15 for testing. Then I'd spend twice as long updating the documentation on how to use it, and how you can't use Pokey@4000 or RAM@4000 at the same time. These days 10 minutes of hobby coding is a luxury I don't have, and probably won't for weeks. After that there are some more important things to add/work on, but eventually... 3 Quote Link to comment Share on other sites More sharing options...
Cybearg Posted October 22, 2014 Share Posted October 22, 2014 There are presently a few features that assembly language programmers have over us right now, the main ones being fine-scrolling and zone-based changes. Out of curiosity, have any of those tough nuts been cracked? Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 23, 2014 Author Share Posted October 23, 2014 No nuts cracked, tough or otherwise. When I get a chance to get back to it, I'll be looking to tune performance before launching into new features. Quote Link to comment Share on other sites More sharing options...
+frankodragon Posted October 27, 2014 Share Posted October 27, 2014 Somehow I was able to get rid of the "label mismatch" and memory errors by moving banks around. So what do I do when half of the graphics are stored in bank 1, the other half of graphics along with other code in bank 2? Do I need a goto function? So far, I'm getting either getting a scrambled screen or a blank screen. And with 'drawscreen" is that needed for both source and target? In other words, where the incgraphics are, along with where I put the "plotsprites"? Quote Link to comment Share on other sites More sharing options...
CPUWIZ Posted October 27, 2014 Share Posted October 27, 2014 AFAICT, you can't do that, unless they are not displayed at the same time (read: same frame). Banking in the middle of the display, would probably result in some pretty strange looking stuff. It is completely unpredictable for the processing units, even if the same speed logic for the bank switching is used. 1 Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 27, 2014 Author Share Posted October 27, 2014 Just to elaborate on what CPUWIZ is saying, all of the banks (except the last) share the same address space. So graphics in bank 1 can't be displayed at the same time as graphics in bank 2. If you're only wanting to display bank 1 graphics, you'd stick the incgraphic in that bank, along with a drawscreen somewhere in the code there. The plotsprite can happen in any bank, even one without the graphics in question. Plotsprite just sets up MARIA's instructions to display that object, but you don't need to be in the bank with the graphics until the "drawscreen" Your 7800basic program also runs during the visible screen, so its important not to switch away from the bank with the graphics until the visible screen has been drawn. To accomplish that, either have a bunch of program code running there, or wait for the visible screen to complete with the "drawwait" command" 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.