clmiller Posted December 23, 2013 Share Posted December 23, 2013 Hi, I've been able to cut my teeth on bB with the great support and documentation here. Great stuff. And I've lucked into being able to spend a little R&D time in the day job by making a silly car game (our company makes gates for airport parking lanes, ha). I'm running into one of those errors that I can't track down. When compiling cxr.bas - no problem. It's a thin app consisting of a single title screen. When compiling ctr.bas - it throws a common error that I don't know how to diagnose. It has four different title screens included, each with variables renamed to keep them from colliding. Nonetheless, there is some trouble. DASM V2.20.07, Macro Assembler ©1988-2003 bytes of ROM space left in bank 1 bytes of ROM space left in bank 2 bytes of ROM space left in bank 3 bytes of ROM space left in bank 4 -19 bytes of ROM space left in bank 1 segment: 1fd4 eqm vs current org: 1fe7 ctr.bas.asm (5036): error: Origin Reverse-indexed. Aborting assembly Errors were encountered during assembly. I've attached it just so you can compare. I'm happy to do more leg work tracking it down, if you have any more suggestions for me. CXR.zip Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted December 23, 2013 Share Posted December 23, 2013 The message "-19 bytes of ROM space left in bank 1" indicates that bank 1 is compiling/assembling to more than 4096 bytes. The next two lines indicate that an ORG statement is trying to set the address of the code that follows to $1FD4, but the code that precedes the ORG statement goes up through address $1FE6, such that the next address should be $1FE7, not $1FD4. "Origin Reverse-indexed" means an ORG statement is trying to set an address to some section of ROM that's already been used up. To correct this, you'll need to find a way to squeeze bank 1 down by at least 19 bytes. Note that a non-bankswitched program may compile just fine in 4K, but run out of ROM space when you try to add bankswitching, because batari Basic has to reserve some of the higher addresses for the bankswitching code plus the bankswitching hotspots, whereas those addresses are available for your code in a non-bankswitched program. Glancing at your code, I see some places where you can reclaim some bytes. I can't copy and paste them into my reply due to the forum software not playing well with IE11, but anywhere you assign the same value to several variables, you can save ROM (and cycles) by putting them on one line, as follows: crashed=0:score=0:crashcountdown=0:AUDV0=0:AUDV1=0:demoMode=0:musicTimer=0 Notice how I took out "AUDC0=5" and "AUDC1=8," since they aren't being set to 0. If you put all the variables that are being set to 0 on one line (or if they won't fit, two lines, three lines, etc.), and put all the variables that are being set to 5 on another line, and so forth, you can save ROM and cycles. Using the optimization feature might do this for you automatically (I'm not sure, because I don't use it)-- but if so, I expect that you'd at least need to put all the lines that set variables to 0 together (i.e., don't insert a line that sets a variable to 5 in the middle of lines that set other variables to 0). 2 Quote Link to comment Share on other sites More sharing options...
bogax Posted December 23, 2013 Share Posted December 23, 2013 (edited) There's lots of redundancy in yourcode that could be removed to savesome bytes.Here's a small example (untested) x = player0x - player1x y = player1x - player0x if player0x > player1x && x > 30 then bmp_player0_index=24 if player0x > player1x && x < 31 then bmp_player0_index=16 if player0x > player1x && x < 16 then bmp_player0_index=8 if player0x > player1x && x < 9 then bmp_player0_index=0 if player0x = player1x then bmp_player0_index=0 if player0x < player1x && y > 30 then bmp_player0_index=24 if player0x < player1x && y < 31 then bmp_player0_index=16 if player0x < player1x && y < 16 then bmp_player0_index=8 if player0x < player1x && y < 9 then bmp_player0_index=0 if player1x > 140 then player1x = 24 if player0x < 11 then player0x = 140 I'm not sure if you need x, y elsewheremaybe temp1 would be enough x = player0x - player1x y = player1x - player0x if player0x = player1x then bmp_player0_index=0 : goto skip if player0x > player1x then temp1 = x else temp1 = y if temp1 > 30 then bmp_player0_index=24 if temp1 < 31 then bmp_player0_index=16 if temp1 < 16 then bmp_player0_index=8 if temp1 < 9 then bmp_player0_index=0 skip if player1x > 140 then player1x = 24 if player0x < 11 then player0x = 140 looks like there's a number of placeswhere you might use tablesthis one's tricky because it involvesscore but I think this will work checkscore if curlevel = 0 then goto level1scorecheck if curlevel = 1 then goto level2scorecheck if curlevel = 2 then goto level3scorecheck if curlevel = 3 then goto level4scorecheck return level1scorecheck if player0x > 140 then laneCar1 = 0: player0x = 1: player0y = 0: score = score + 50 if player1x > 140 then laneCar2 = 0: player1x = 1: player1y = 0: score = score + 50 return level2scorecheck if player0x > 140 then laneCar1 = 0: player0x = 1: player0y = 0: score = score + 75 if player1x > 140 then laneCar2 = 0: player1x = 1: player1y = 0: score = score + 75 return level3scorecheck if player0x > 140 then laneCar1 = 0: player0x = 1: player0y = 0: score = score + 110 if player1x > 140 then laneCar2 = 0: player1x = 1: player1y = 0: score = score + 110 return level4scorecheck if player0x > 140 then laneCar1 = 0: player0x = 1: player0y = 0: score = score + 240 if player1x > 140 then laneCar2 = 0: player1x = 1: player1y = 0: score = score + 240 return assuming curlevel can only be 0..3and the increment of score will be < 256 edit: the increment would need to be < 100 99 being the largest BCD number to fit in a byte. $99 in hex, 153 in decimal you need temp1, scr_inc[curlevel] wontwork with score checkscore if player0x > 140 then laneCar1 = 0: player0x = 1: player0y = 0: temp1 = scr_inc[curlevel]: score = score + temp1 if player1x > 140 then laneCar2 = 0: player1x = 1: player1y = 0: temp1 = scr_inc[curlevel]: score = score + temp1 return data scr_inc 50, 75, 110, 240 end use return thisbank if you canif you can get your if-then statementsclose enough you can save a goto if laneCar1 = 1 && joy0fire && joy0up then goto checkcollisions2 if laneCar1 = 2 && joy0fire && joy0left then goto checkcollisions2 if laneCar1 = 2 && joy0fire && joy0right then goto checkcollisions2 if laneCar1 = 3 && joy0fire && joy0down then goto checkcollisions2 if !joy0fire then skip if laneCar1 = 1 && joy0up then gochkcol2 if laneCar1 = 2 && joy0left then gochkcol2 if laneCar1 = 2 && joy0right then gochkcol2 if laneCar1 <> 3 || !joy0down then skip gochkcol2 goto checkcollisions2 skip or goto checkcollisions2 continue . . . checkcollisions2 if !joy0fire then skip if laneCar1 = 1 && joy0up then chkcol2 if laneCar1 = 2 && joy0left then chkcol2 if laneCar1 = 2 && joy0right then chkcol2 if laneCar1 = 3 && joy0down then chkcol2 skip goto continue chkcol2 it appears that bank2 is too big also Edited December 26, 2013 by bogax 1 Quote Link to comment Share on other sites More sharing options...
clmiller Posted December 25, 2013 Author Share Posted December 25, 2013 Thanks! Moving the title screen to bank4 and cleaning up my code really cut down on my bytes. And using tables with the data statement is a huge help. Merry Christmas all. Quote Link to comment Share on other sites More sharing options...
bogax Posted December 25, 2013 Share Posted December 25, 2013 heck! darn! (other obscenities as required)I goofed it.if scr_inc were less than 99 it'll fitfor increments greater than 99 somethinglike this could work (barring some asm) checkscore if player0x > 140 then laneCar1 = 0: player0x = 1: player0y = 0: goto inc_scr if player1x > 140 then laneCar2 = 0: player1x = 1: player1y = 0: goto inc_scr return thisbank inc_scr on curlevel goto cl0 cl1 cl2 cl3 cl0 score = score + 50 : return thisbank cl1 score = score + 75 : return thisbank cl2 score = score + 110 : return thisbank cl3 score = score + 240 : return thisbank Quote Link to comment Share on other sites More sharing options...
bogax Posted December 25, 2013 Share Posted December 25, 2013 (edited) that annoys meyou could try thisno idea if it will work checkscore if player0x > 140 then laneCar1 = 0: player0x = 1: player0y = 0: gosub scr_plus if player1x > 140 then laneCar2 = 0: player1x = 1: player1y = 0: gosub scr_plus return thisbank rem table of bcd values (in hex) rem two consecutive bytes per value rem big endian data scr_inc $00, $50 $00, $75 $01, $10 $02, $40 end rem equate score_increment_table to what ever your table is named rem equate score_increment_table_pointer to a variable that rem contains an index into the table, two bytes per index rem 0 is the first two byte item in bytes 0, 1 of the table rem 1 is the second two byte item in bytes 2, 3 of the table rem etc const score_increment_table = scr_inc const score_increment_table_pointer = curlevel rem subroutine to add 4 digits from the table to score scr_plus asm lda score_increment_table_pointer sec rol tax sed lda score+2 adc score_increment_table,x sta score+2 dex lda score+1 adc score_increment_table,x sta score+1 lda score adc #$00 sta score cld end return thisbank rem subroutine to subtract 4 digits from the score scr_minus asm lda score_increment_table_pointer sec rol tax sed sec lda score+2 sbc score_increment_table,x sta score+2 dex lda score+1 sbc score_increment_table,x sta score+1 lda score sbc #$00 sta score cld end return thisbank Edited December 25, 2013 by bogax 1 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.