Jump to content
IGNORED

Question for those who know the asm behind bB


jbs30000

Recommended Posts

I discovered that the bB alternative to using the playfield: statement is to read data into the playfield variable doing something like

for a = 0 to 48

playfield[a]=datalabel[a]

next

 

Does anybody know the bB alternative to using pfcolors?

 

I've studied the asm and know the two main variables are pfcolortable and the data statements generated by pfcolors are stored under the label pfcolorlabelnumber (I'm not sure how the number is assigned). I know that the pfcolortable somehow points to the pfcolorlabel, but I'm not sure how to do that in bB.

Edited by jbs30000
Link to comment
Share on other sites

pfcolors stores its data in ROM, so you would need to map it to Superchip RAM if you want to do a data copy like that.

 

Also, pfcolors data is stored in a funky manner - the kernel uses X as a playfield line counter and it counts down by 4 each playfield line, so pfcolor data is stored every 4th byte. Multiple pfcolor tables, if they exist, are then interleaved in that 4-byte space.

Link to comment
Share on other sites

I noticed in the asm generated that for my 32x32 size screen the color table was four bytes across and 32 bytes down.

 

Anyway, I'm just curious if there's a simple way to point the playfield colors to a data table. In the asm there's a lot code which I believe is trying to decide what to based on the screen size:

; pfcolors:
lda	# $0E
sta	COLUPF
ifconst	pfres
lda	#>(pfcolorlabel13-132+pfres*4)
else
lda	#>(pfcolorlabel13-84)
endif
sta	pfcolortable+1
ifconst	pfres
lda	#<(pfcolorlabel13-132+pfres*4)
else
lda	#<(pfcolorlabel13-84)
endif
sta	pfcolortable

So I'm just curious how to get rid of checking for pfres and just setting the pointer to the colortable or, if possible, data statements. I've tried pfcolortable=pfcolorlabel13 but that doesn't work. I guess if it can't be done in bB and needs inline asm that's fine too. Thanks.

Edited by jbs30000
Link to comment
Share on other sites

I'm just curious how to get rid of checking for pfres and just setting the pointer to the colortable or, if possible, data statements.

pfcolortable is a 2-byte pointer consisting of a lo byte and a hi byte, so you need to set both bytes if you want to manually point it to a color table. The easiest way to do that in batari Basic is to define some constants for the lo byte value and the hi byte value. For example, suppose you've created 4 color tables in ROM for your playfield, and you've used the labels table_1, table_2, table_3, and table_4. Each of those labels is a 16-bit address, so you can define 8 constants for the lo bytes and hi bytes:

 

   const table_1_lo = #<(table_1 - 84)
  const table_1_hi = #>(table_1 - 84)
  const table_2_lo = #<(table_2 - 84)
  const table_2_hi = #>(table_2 - 84)
  const table_3_lo = #<(table_3 - 84)
  const table_3_hi = #>(table_3 - 84)
  const table_4_lo = #<(table_4 - 84)
  const table_4_hi = #>(table_4 - 84)

That's if you aren't using pfres. If you *are* using pfres, you would use

 

   const table_1_lo = #<(table_1 - 132 + pfres * 4)
  const table_1_hi = #>(table_1 - 132 + pfres * 4)
  const table_2_lo = #<(table_2 - 132 + pfres * 4)
  const table_2_hi = #>(table_2 - 132 + pfres * 4)
  const table_3_lo = #<(table_3 - 132 + pfres * 4)
  const table_3_hi = #>(table_3 - 132 + pfres * 4)
  const table_4_lo = #<(table_4 - 132 + pfres * 4)
  const table_4_hi = #>(table_4 - 132 + pfres * 4)

I should note that I'm basing this on what the assembly listing looks like, and I haven't worked out what all the extra numbers are for (i.e., why the kernel needs them). But notice that if pfres is 12 (the default playfield resolution), then pfres * 4 is 48, and - 132 + 48 is - 84. So if you don't want to put those calculations in the const statements, you can just work out what the numbers should be for your pfres setting. For example, if you're using a pfres of 32, then pfres * 4 is 128, and - 132 + 128 is - 4, so you'd use

 

   const table_1_lo = #<(table_1 - 4)
  const table_1_hi = #>(table_1 - 4)
  const table_2_lo = #<(table_2 - 4)
  const table_2_hi = #>(table_2 - 4)
  const table_3_lo = #<(table_3 - 4)
  const table_3_hi = #>(table_3 - 4)
  const table_4_lo = #<(table_4 - 4)
  const table_4_hi = #>(table_4 - 4)

Anyway, when you want to manually point the pfcolortable to your ROM data, you could then use something like

 

   pfcolortable[0] = table_1_lo
  pfcolortable[1] = table_1_hi

Or better yet, you could dim the lo byte and hi byte of the pointer:

 

   dim pfcolortable_lo = pfcolortable
  dim pfcolortable_hi = pfcolortable + 1

Then you could set the pointers like this:

 

   pfcolortable_lo = table_1_lo
  pfcolortable_hi = table_1_hi

Michael

Link to comment
Share on other sites

  • 6 years later...

pfcolortable is a 2-byte pointer consisting of a lo byte and a hi byte, so you need to set both bytes if you want to manually point it to a color table. The easiest way to do that in batari Basic is to define some constants for the lo byte value and the hi byte value. For example, suppose you've created 4 color tables in ROM for your playfield, and you've used the labels table_1, table_2, table_3, and table_4. Each of those labels is a 16-bit address, so you can define 8 constants for the lo bytes and hi bytes:

 

const table_1_lo = #<(table_1 - 84)
   const table_1_hi = #>(table_1 - 84)
   const table_2_lo = #<(table_2 - 84)
   const table_2_hi = #>(table_2 - 84)
   const table_3_lo = #<(table_3 - 84)
   const table_3_hi = #>(table_3 - 84)
   const table_4_lo = #<(table_4 - 84)
   const table_4_hi = #>(table_4 - 84)
That's if you aren't using pfres. If you *are* using pfres, you would use

 

const table_1_lo = #<(table_1 - 132 + pfres * 4)
   const table_1_hi = #>(table_1 - 132 + pfres * 4)
   const table_2_lo = #<(table_2 - 132 + pfres * 4)
   const table_2_hi = #>(table_2 - 132 + pfres * 4)
   const table_3_lo = #<(table_3 - 132 + pfres * 4)
   const table_3_hi = #>(table_3 - 132 + pfres * 4)
   const table_4_lo = #<(table_4 - 132 + pfres * 4)
   const table_4_hi = #>(table_4 - 132 + pfres * 4)
I should note that I'm basing this on what the assembly listing looks like, and I haven't worked out what all the extra numbers are for (i.e., why the kernel needs them). But notice that if pfres is 12 (the default playfield resolution), then pfres * 4 is 48, and - 132 + 48 is - 84. So if you don't want to put those calculations in the const statements, you can just work out what the numbers should be for your pfres setting. For example, if you're using a pfres of 32, then pfres * 4 is 128, and - 132 + 128 is - 4, so you'd use

 

const table_1_lo = #<(table_1 - 4)
   const table_1_hi = #>(table_1 - 4)
   const table_2_lo = #<(table_2 - 4)
   const table_2_hi = #>(table_2 - 4)
   const table_3_lo = #<(table_3 - 4)
   const table_3_hi = #>(table_3 - 4)
   const table_4_lo = #<(table_4 - 4)
   const table_4_hi = #>(table_4 - 4)
Anyway, when you want to manually point the pfcolortable to your ROM data, you could then use something like

 

pfcolortable[0] = table_1_lo
   pfcolortable[1] = table_1_hi
Or better yet, you could dim the lo byte and hi byte of the pointer:

 

dim pfcolortable_lo = pfcolortable
   dim pfcolortable_hi = pfcolortable + 1
Then you could set the pointers like this:

 

pfcolortable_lo = table_1_lo
   pfcolortable_hi = table_1_hi
Michael

 

Alright, to reopen this thread, I'm trying to do some playfield color scrolling with my next game. When I scroll horizontally (up/down), I naturally want the colors to playfield colors to scroll as well. I'm using the standard playfield resolution and have applied everything you put here. It worked until I tried to assign pfcolortable_lo (and _hi) to what I defined in my const. It errors and reports back with Colors1A_lo (what I called my const) 00ac ???? and Colors1A_hi 00ff ???? in messages. I have no idea what I am doing wrong.

 

Here's some of my code that has to do with this. BTW, this is, as of this moment, using 32K. In the first bank I have:

 

const Colors1A_lo = #<(Level1ColorsA - 84)
const Colors1A_hi = #>(Level1ColorsA - 84)
then a touch later:
dim pfcolortable_lo = pfcolortable
dim pfcolortable_hi = pfcolortable + 1
In bank 8 I have my actual color table: Level1ColorsA
Level1ColorsA
pfcolors:
$B6
$B6
$B4
$B4
$C4
$C4
$D4
$D4
$E4
$E4
$F4
$F4
$24
$24
$34
$34
$44
$44
$54
$54
$64
$64
$74
$74
$84
$84
$86
$86
$88
$88
$8A
$8A
$8C
$8C
$8E
$8E
end
return otherbank
But in bank 6, where I want to do my colortable calculations, this is where I put:
pfcolortable_lo = Colors1A_lo
pfcolortable_hi = Colors1A_hi
And that's when I get the error when I try to compile. I tried moving it to bank 1 with no luck.
Now I know that Level1ColorsA is a routine label, but when I tried just using pfcolors it returns with the same problem. I also just noticed that when using Level1ColorsA it also shows up in that list too of errors. But then so does pfcolors when I tried using that instead.
Any thoughts?
Edited by Sprybug
  • Like 1
Link to comment
Share on other sites

I haven't done anything with bB in a couple of years-- my new computer doesn't even have it installed, and my old computer isn't handy right now-- so all of that from six years ago is kind of fuzzy in my mind! ;) But I think that what I wrote probably applied to a standard or non-bankswitched kernel. Since I don't have access to a bB installation right now, I can't check whether the numbers are the same if you're using bankswitching.

 

Anyway, if I remember correctly, when you're using bankswitching you generally need to keep your display-related data in the same bank as the drawscreen routine, because when the 2600 is performing the display kernel (drawing the screen) it needs to be able to read the data from ROM without switching banks as it's drawing. The exception is when the data is loaded into RAM, as is normally the case with the playfield graphics. However, that doesn't include the playfield colors, since the data resides in ROM and only the pointers are in RAM.

 

Now, even if you've got the data in the wrong bank, that shouldn't make the code error out during compile (unless the compiler is "smart" about such things, which I don't think it was back when I was still using bB)-- I think the worst that should happen would be that the playfield colors aren't what you expected, since they're being read from the "correct" address but the bank they're in isn't selected, hence the kernel will be reading "garbage" data from where it thinks the playfield color table is.

 

You should post the messages that you're getting, so we can read the full text. You don't need to post your code if you don't want to release it, but being able to see a screenshot of the exact message should help us.

Link to comment
Share on other sites

I haven't done anything with bB in a couple of years-- my new computer doesn't even have it installed, and my old computer isn't handy right now-- so all of that from six years ago is kind of fuzzy in my mind! ;) But I think that what I wrote probably applied to a standard or non-bankswitched kernel. Since I don't have access to a bB installation right now, I can't check whether the numbers are the same if you're using bankswitching.

 

Anyway, if I remember correctly, when you're using bankswitching you generally need to keep your display-related data in the same bank as the drawscreen routine, because when the 2600 is performing the display kernel (drawing the screen) it needs to be able to read the data from ROM without switching banks as it's drawing. The exception is when the data is loaded into RAM, as is normally the case with the playfield graphics. However, that doesn't include the playfield colors, since the data resides in ROM and only the pointers are in RAM.

 

Now, even if you've got the data in the wrong bank, that shouldn't make the code error out during compile (unless the compiler is "smart" about such things, which I don't think it was back when I was still using bB)-- I think the worst that should happen would be that the playfield colors aren't what you expected, since they're being read from the "correct" address but the bank they're in isn't selected, hence the kernel will be reading "garbage" data from where it thinks the playfield color table is.

 

You should post the messages that you're getting, so we can read the full text. You don't need to post your code if you don't want to release it, but being able to see a screenshot of the exact message should help us.

Actually, there's enough information to play around with this until I get it. It's good to know how the PF color tables are organized in BB and the math involved. It's just a matter of figuring out the equations to make it all work. I should be able to do it my own way with that info. But, judging by what I read in the earlier part of this forum, does that mean I can only have a maximum of 4 PF color tables in my code, if that's all the space that is partitioned in the table allocations? Do you happen to recall this?

  • Like 1
Link to comment
Share on other sites

 

Alright, to reopen this thread, I'm trying to do some playfield color scrolling with my next game. When I scroll horizontally (up/down), I naturally want the colors to playfield colors to scroll as well. I'm using the standard playfield resolution and have applied everything you put here. It worked until I tried to assign pfcolortable_lo (and _hi) to what I defined in my const. It errors and reports back with Colors1A_lo (what I called my const) 00ac ???? and Colors1A_hi 00ff ???? in messages. I have no idea what I am doing wrong.

 

Here's some of my code that has to do with this. BTW, this is, as of this moment, using 32K. In the first bank I have:

 

const Colors1A_lo = #<(Level1ColorsA - 84)
const Colors1A_hi = #>(Level1ColorsA - 84)
then a touch later:
dim pfcolortable_lo = pfcolortable
dim pfcolortable_hi = pfcolortable + 1
In bank 8 I have my actual color table: Level1ColorsA
Level1ColorsA
pfcolors:
$B6
$B6
$B4
$B4
$C4
$C4
$D4
$D4
$E4
$E4
$F4
$F4
$24
$24
$34
$34
$44
$44
$54
$54
$64
$64
$74
$74
$84
$84
$86
$86
$88
$88
$8A
$8A
$8C
$8C
$8E
$8E
end
return otherbank
But in bank 6, where I want to do my colortable calculations, this is where I put:
pfcolortable_lo = Colors1A_lo
pfcolortable_hi = Colors1A_hi
And that's when I get the error when I try to compile. I tried moving it to bank 1 with no luck.
Now I know that Level1ColorsA is a routine label, but when I tried just using pfcolors it returns with the same problem. I also just noticed that when using Level1ColorsA it also shows up in that list too of errors. But then so does pfcolors when I tried using that instead.
Any thoughts?

 

 

First off, you should post your code

 

Level1ColorsA is the name of your routine/label in Bb but in the assembly code that Bb emits it will have a "." appended, ".Level1ColorsA"

 

I don't recall about pfcolors specifically, but Bb probably moves the table to the end of the code and (I believe) to the last bank for multi bank stuff.

and (as I believe Batari was alluding to above) Bb rearranges the table

 

Compile something simple and see what Bb does with it.

you may have to coax Bb (or DASM really) to produce a .lst file (its a DASM switch somewhere in the make file)

Actually, that's an assumption. I've never used Visual Bb (and another assumption, I assume you're using Visual Bb)

 

Once you've figured out what's going on I'd suggest you put the tables in a data statement.

Bb won't monkey with it and you'll have better control.

Link to comment
Share on other sites

Actually, there's enough information to play around with this until I get it. It's good to know how the PF color tables are organized in BB and the math involved. It's just a matter of figuring out the equations to make it all work. I should be able to do it my own way with that info. But, judging by what I read in the earlier part of this forum, does that mean I can only have a maximum of 4 PF color tables in my code, if that's all the space that is partitioned in the table allocations? Do you happen to recall this?

More tables then 4 should be possible. As long you got room in the bank you should be good. You might have to coax BB a little bit with the naming of the tables, but in the end you have control of re-assigning the pointer whether through BB or asm.

 

 

Alright, to reopen this thread, I'm trying to do some playfield color scrolling with my next game. When I scroll horizontally (up/down), I naturally want the colors to playfield colors to scroll as well. I'm using the standard playfield resolution and have applied everything you put here. It worked until I tried to assign pfcolortable_lo (and _hi) to what I defined in my const. It errors and reports back with Colors1A_lo (what I called my const) 00ac ???? and Colors1A_hi 00ff ???? in messages. I have no idea what I am doing wrong.

It looks like it is compiling the constants correctly, and DASM is choking on something else it can't compile. The list file will immediately take you the line of code it broke at, and you can see what it really has trouble with. The list file will have your BB code, and then the asssembly it's compiling it into.

Link to comment
Share on other sites

 

Alright, to reopen this thread, I'm trying to do some playfield color scrolling with my next game. When I scroll horizontally (up/down), I naturally want the colors to playfield colors to scroll as well. I'm using the standard playfield resolution and have applied everything you put here. It worked until I tried to assign pfcolortable_lo (and _hi) to what I defined in my const. It errors and reports back with Colors1A_lo (what I called my const) 00ac ???? and Colors1A_hi 00ff ???? in messages. I have no idea what I am doing wrong.

 

Here's some of my code that has to do with this. BTW, this is, as of this moment, using 32K. In the first bank I have:

 

const Colors1A_lo = #<(Level1ColorsA - 84)
const Colors1A_hi = #>(Level1ColorsA - 84)
then a touch later:

dim pfcolortable_lo = pfcolortable
dim pfcolortable_hi = pfcolortable + 1
In bank 8 I have my actual color table: Level1ColorsA

Level1ColorsA
pfcolors:
$B6
$B6
$B4
$B4
$C4
$C4
$D4
$D4
$E4
$E4
$F4
$F4
$24
$24
$34
$34
$44
$44
$54
$54
$64
$64
$74
$74
$84
$84
$86
$86
$88
$88
$8A
$8A
$8C
$8C
$8E
$8E
end
return otherbank
But in bank 6, where I want to do my colortable calculations, this is where I put:

pfcolortable_lo = Colors1A_lo
pfcolortable_hi = Colors1A_hi
And that's when I get the error when I try to compile. I tried moving it to bank 1 with no luck.
Now I know that Level1ColorsA is a routine label, but when I tried just using pfcolors it returns with the same problem. I also just noticed that when using Level1ColorsA it also shows up in that list too of errors. But then so does pfcolors when I tried using that instead.
Any thoughts?

 

 

 

Here I've taken your code and altered it to illustrate some stuff, mostly why you need the .lst file

 

I added another pfcolors statement so you can see what happens

 

I added some Bb equivalents to the pfcolors statements (that refer to the table Bb produces)

 

I added a data statement with the table (same data) called my_pfcolors_table

 

The junk data is just to push Bb's pfcolors table across a page boundary

(I used the my_pfcolors_table data. In retrospect, I should have used something completely

different to set it apart)

 

The rem statements at the end are just to mark the end of the Bb code in the .lst file

 

I've only included the pertinent part of the .list file (well, some. it doesn't show why Bb does

what it does)

 

this compiles but is UNTESTED (and it doesn't do anything)

 set kernel_options pfcolors

 
 
 dim pfcolortable_lo = pfcolortable
 dim pfcolortable_hi = pfcolortable + 1
 
 
 rem  this just gives a name to use that wont change if
 rem  the label pfcolorlabel3 between compiles
 
 const Bb_pfcolor_table_01 = pfcolorlabel13-84
 
 const Colors1A_lo = <Bb_pfcolor_table_01
 const Colors1A_hi = >Bb_pfcolor_table_01
 
 
Level1ColorsA
 pfcolors:
 $B6
 $B6
 $B4
 $B4
 $C4
 $C4
 $D4
 $D4
 $E4
 $E4
 $F4
 $F4
 $24
 $24
 $34
 $34
 $44
 $44
 $54
 $54
 $64
 $64
 $74
 $74
 $84
 $84
 $86
 $86
 $88
 $88
 $8A
 $8A
 $8C
 $8C
 $8E
 $8E
end
 
 COLUPF = $B6
 pfcolortable_hi = Colors1A_hi
 pfcolortable_lo = Colors1A_lo
 
 
More_pfcolors
 pfcolors:
 $A0
 $A1
 $A2
 $A3
 $A4
 $A5
 $A6
 $A7
 $A8
 $A9
 $AA
 $AB
 $AC
 $AD
 $AE
 $AF
 $B0
 $B1
 $B2
 $B3
 $B4
 $B5
 $B6
 $B7
 $B8
 $B9
 $BB
 $BA
 $BC
 $BD
 $BE
 $BF
 $C0
 $C1
 $C2
 $C3
end
 
 
 const More_pfcolors_lo = <(Bb_pfcolor_table_01 + 1)
 const More_pfcolors_hi = >(Bb_pfcolor_table_01 + 1)
 
 
 COLUPF = $A0
 pfcolortable_hi = More_pfcolors_hi
 pfcolortable_lo = More_pfcolors_lo
 
 
 
 const my_colors_lo = <(my_pfcolors_table - 84)
 const my_colors_hi = >(my_pfcolors_table - 84)
 
 
 data my_pfcolors_table
 $B6,$A0,0,0
 $B4,$A1,0,0
 $B4,$A2,0,0
 $C4,$A3,0,0
 $C4,$A4,0,0
 $D4,$A5,0,0
 $D4,$A6,0,0
 $E4,$A7,0,0
 $E4,$A8,0,0
 $F4,$A9,0,0
 $F4,$AA,0,0
 $24,$AB,0,0
 $24,$AC,0,0
 $34,$AD,0,0
 $34,$AE,0,0
 $44,$AF,0,0
 $44,$B0,0,0
 $54,$B1,0,0
 $54,$B2,0,0
 $64,$B3,0,0
 $64,$B4,0,0
 $74,$B5,0,0
 $74,$B6,0,0
 $84,$B7,0,0
 $84,$B8,0,0
 $86,$B9,0,0
 $86,$BA,0,0
 $88,$BC,0,0
 $88,$BD,0,0
 $8A,$BE,0,0
 $8A,$BF,0,0
 $8C,$C0,0,0
 $8C,$C1,0,0
 $8E,$C2,0,0
 $8E,$C3,0,0
end
 
 COLUPF = my_pfcolors_table[0]
 
 pfcolortable_lo = my_colors_lo
 pfcolortable_hi = my_colors_hi
 
 
 data junk
 $B6,$A0,0,0
 $B4,$A1,0,0
 $B4,$A2,0,0
 $C4,$A3,0,0
 $C4,$A4,0,0
 $D4,$A5,0,0
 $D4,$A6,0,0
 $E4,$A7,0,0
 $E4,$A8,0,0
 $F4,$A9,0,0
 $F4,$AA,0,0
 $24,$AB,0,0
 $24,$AC,0,0
 $34,$AD,0,0
 $34,$AE,0,0
 $44,$AF,0,0
 $44,$B0,0,0
 $54,$B1,0,0
 $54,$B2,0,0
 $64,$B3,0,0
 $64,$B4,0,0
 $74,$B5,0,0
 $74,$B6,0,0
 $84,$B7,0,0
 $84,$B8,0,0
 $86,$B9,0,0
 $86,$BA,0,0
 $88,$BC,0,0
 $88,$BD,0,0
 $8A,$BE,0,0
 $8A,$BF,0,0
 $8C,$C0,0,0
 $8C,$C1,0,0
 $8E,$C2,0,0
 $8E,$C3,0,0
end
 
 
 rem the rest of the code
 rem
 rem
 rem
 rem
 
   1634  f45e    .L00  ;  set kernel_options pfcolors


   1635  f45e
   1636  f45e    .
   1637  f45e ;
   1638  f45e
   1639  f45e    .
   1640  f45e ;
   1641  f45e
   1642  f45e    .L01  ;  dim pfcolortable_lo  =  pfcolortable
   1643  f45e
   1644  f45e    .L02  ;  dim pfcolortable_hi  =  pfcolortable  +  1
   1645  f45e
   1646  f45e    .
   1647  f45e ;
   1648  f45e
   1649  f45e    .
   1650  f45e ;
   1651  f45e
   1652  f45e    .L03  ;  rem  this just gives a name to use that wont change if
   1653  f45e
   1654  f45e    .L04  ;  rem  the label pfcolorlabel3 between compiles
   1655  f45e
   1656  f45e    .
   1657  f45e ;
   1658  f45e
   1659  f45e    .L05  ;  const Bb_pfcolor_table_01  =  pfcolorlabel13 - 84
   1660  f45e
   1661  f45e    .
   1662  f45e ;
   1663  f45e
   1664  f45e    .L06  ;  const Colors1A_lo  =   < Bb_pfcolor_table_01
   1665  f45e
   1666  f45e    .L07  ;  const Colors1A_hi  =   > Bb_pfcolor_table_01
   1667  f45e
   1668  f45e    .
   1669  f45e ;
   1670  f45e
   1671  f45e    .
   1672  f45e ;
   1673  f45e
   1674  f45e    .Level1ColorsA
   1675  f45e ; Level1ColorsA
   1676  f45e
   1677  f45e    .L08  ;  pfcolors:
   1678  f45e
   1679  f45e        a9 b6       lda # $B6
   1680  f460        85 08       sta COLUPF
   1681  f462   -       ifconst pfres
   1682  f462   -       lda #>(pfcolorlabel13-132+pfres*pfwidth)
   1683  f462       else
   1684  f462        a9 f5       lda #>(pfcolorlabel13-84)
   1685  f464       endif
   1686  f464        85 f1       sta pfcolortable+1
   1687  f466   -       ifconst pfres
   1688  f466   -       lda #<(pfcolorlabel13-132+pfres*pfwidth)
   1689  f466       else
   1690  f466        a9 67       lda #<(pfcolorlabel13-84)
   1691  f468       endif
   1692  f468        85 f0       sta pfcolortable
   1693  f46a    .
   1694  f46a ;
   1695  f46a
   1696  f46a    .L09  ;  COLUPF  =  $B6
   1697  f46a
   1698  f46a        a9 b6       LDA #$B6
   1699  f46c        85 08       STA COLUPF
   1700  f46e    .L010 ;  pfcolortable_hi  = Colors1A_hi
   1701  f46e
   1702  f46e        a9 f5       LDA #Colors1A_hi
   1703  f470        85 f1       STA pfcolortable_hi
   1704  f472    .L011 ;  pfcolortable_lo  = Colors1A_lo
   1705  f472
   1706  f472        a9 67       LDA #Colors1A_lo
   1707  f474        85 f0       STA pfcolortable_lo
   1708  f476    .
   1709  f476 ;
   1710  f476
   1711  f476    .
   1712  f476 ;
   1713  f476
   1714  f476    .More_pfcolors
   1715  f476 ; More_pfcolors
   1716  f476
   1717  f476    .L012 ;  pfcolors:
   1718  f476
   1719  f476        a9 a0       lda # $A0
   1720  f478        85 08       sta COLUPF
   1721  f47a   -       ifconst pfres
   1722  f47a   -       lda #>(pfcolorlabel13-131+pfres*pfwidth)
   1723  f47a       else
   1724  f47a        a9 f5       lda #>(pfcolorlabel13-83)
   1725  f47c       endif
   1726  f47c        85 f1       sta pfcolortable+1
   1727  f47e   -       ifconst pfres
   1728  f47e   -       lda #<(pfcolorlabel13-131+pfres*pfwidth)
   1729  f47e       else
   1730  f47e        a9 68       lda #<(pfcolorlabel13-83)
   1731  f480       endif
   1732  f480        85 f0       sta pfcolortable
   1733  f482    .
   1734  f482 ;
   1735  f482
   1736  f482    .
   1737  f482 ;
   1738  f482
   1739  f482    .L013 ;  const More_pfcolors_lo  = <  ( Bb_pfcolor_table_01  +  1 )
   1740  f482
   1741  f482    .L014 ;  const More_pfcolors_hi  = >  ( Bb_pfcolor_table_01  +  1 )
   1742  f482
   1743  f482    .
   1744  f482 ;
   1745  f482
   1746  f482    .
   1747  f482 ;
   1748  f482
   1749  f482    .L015 ;  COLUPF  =  $A0
   1750  f482
   1751  f482        a9 a0       LDA #$A0
   1752  f484        85 08       STA COLUPF
   1753  f486    .L016 ;  pfcolortable_hi  = More_pfcolors_hi
   1754  f486
   1755  f486        a9 f5       LDA #More_pfcolors_hi
   1756  f488        85 f1       STA pfcolortable_hi
   1757  f48a    .L017 ;  pfcolortable_lo  = More_pfcolors_lo
   1758  f48a
   1759  f48a        a9 68       LDA #More_pfcolors_lo
   1760  f48c        85 f0       STA pfcolortable_lo
   1761  f48e    .
   1762  f48e ;
   1763  f48e
   1764  f48e    .
   1765  f48e ;
   1766  f48e
   1767  f48e    .
   1768  f48e ;
   1769  f48e
   1770  f48e    .L018 ;  const my_colors_lo =   <  ( my_pfcolors_table  -  84 )
   1771  f48e
   1772  f48e    .L019 ;  const my_colors_hi =   >  ( my_pfcolors_table  -  84 )
   1773  f48e
   1774  f48e    .
   1775  f48e ;
   1776  f48e
   1777  f48e    .
   1778  f48e ;
   1779  f48e
   1780  f48e    .L020 ;  data my_pfcolors_table
   1781  f48e
   1782  f48e        4c 1d f5        JMP .skipL020
   1783  f491    my_pfcolors_table
   1784  f491        b6 a0 00 00       .byte.b $B6,$A0,0,0
   1785  f495
   1786  f495        b4 a1 00 00       .byte.b $B4,$A1,0,0
   1787  f499
   1788  f499        b4 a2 00 00       .byte.b $B4,$A2,0,0
   1789  f49d
   1790  f49d        c4 a3 00 00       .byte.b $C4,$A3,0,0
   1791  f4a1
   1792  f4a1        c4 a4 00 00       .byte.b $C4,$A4,0,0
   1793  f4a5
   1794  f4a5        d4 a5 00 00       .byte.b $D4,$A5,0,0
   1795  f4a9
   1796  f4a9        d4 a6 00 00       .byte.b $D4,$A6,0,0
   1797  f4ad
   1798  f4ad        e4 a7 00 00       .byte.b $E4,$A7,0,0
   1799  f4b1
   1800  f4b1        e4 a8 00 00       .byte.b $E4,$A8,0,0
   1801  f4b5
   1802  f4b5        f4 a9 00 00       .byte.b $F4,$A9,0,0
   1803  f4b9
   1804  f4b9        f4 aa 00 00       .byte.b $F4,$AA,0,0
   1805  f4bd
   1806  f4bd        24 ab 00 00       .byte.b $24,$AB,0,0
   1807  f4c1
   1808  f4c1        24 ac 00 00       .byte.b $24,$AC,0,0
   1809  f4c5
   1810  f4c5        34 ad 00 00       .byte.b $34,$AD,0,0
   1811  f4c9
   1812  f4c9        34 ae 00 00       .byte.b $34,$AE,0,0
   1813  f4cd
   1814  f4cd        44 af 00 00       .byte.b $44,$AF,0,0
   1815  f4d1
   1816  f4d1        44 b0 00 00       .byte.b $44,$B0,0,0
   1817  f4d5
   1818  f4d5        54 b1 00 00       .byte.b $54,$B1,0,0
   1819  f4d9
   1820  f4d9        54 b2 00 00       .byte.b $54,$B2,0,0
   1821  f4dd
   1822  f4dd        64 b3 00 00       .byte.b $64,$B3,0,0
   1823  f4e1
   1824  f4e1        64 b4 00 00       .byte.b $64,$B4,0,0
   1825  f4e5
   1826  f4e5        74 b5 00 00       .byte.b $74,$B5,0,0
   1827  f4e9
   1828  f4e9        74 b6 00 00       .byte.b $74,$B6,0,0
   1829  f4ed
   1830  f4ed        84 b7 00 00       .byte.b $84,$B7,0,0
   1831  f4f1
   1832  f4f1        84 b8 00 00       .byte.b $84,$B8,0,0
   1833  f4f5
   1834  f4f5        86 b9 00 00       .byte.b $86,$B9,0,0
   1835  f4f9
   1836  f4f9        86 ba 00 00       .byte.b $86,$BA,0,0
   1837  f4fd
   1838  f4fd        88 bc 00 00       .byte.b $88,$BC,0,0
   1839  f501
   1840  f501        88 bd 00 00       .byte.b $88,$BD,0,0
   1841  f505
   1842  f505        8a be 00 00       .byte.b $8A,$BE,0,0
   1843  f509
   1844  f509        8a bf 00 00       .byte.b $8A,$BF,0,0
   1845  f50d
   1846  f50d        8c c0 00 00       .byte.b $8C,$C0,0,0
   1847  f511
   1848  f511        8c c1 00 00       .byte.b $8C,$C1,0,0
   1849  f515
   1850  f515        8e c2 00 00       .byte.b $8E,$C2,0,0
   1851  f519
   1852  f519        8e c3 00 00       .byte.b $8E,$C3,0,0
   1853  f51d
   1854  f51d    .skipL020
   1855  f51d    .
   1856  f51d ;
   1857  f51d
   1858  f51d    .L021 ;  COLUPF  =  my_pfcolors_table[0]
   1859  f51d
   1860  f51d        a2 00       LDX #0
   1861  f51f        bd 91 f4        LDA my_pfcolors_table,x
   1862  f522        85 08       STA COLUPF
   1863  f524    .
   1864  f524 ;
   1865  f524
   1866  f524    .L022 ;  pfcolortable_lo  = my_colors_lo
   1867  f524
   1868  f524        a9 3d       LDA #my_colors_lo
   1869  f526        85 f0       STA pfcolortable_lo
   1870  f528    .L023 ;  pfcolortable_hi  = my_colors_hi
   1871  f528
   1872  f528        a9 f4       LDA #my_colors_hi
   1873  f52a        85 f1       STA pfcolortable_hi
   1874  f52c    .
   1875  f52c ;
   1876  f52c
   1877  f52c    .
   1878  f52c ;
   1879  f52c
   1880  f52c    .L024 ;  data junk
   1881  f52c
   1882  f52c        4c bb f5        JMP .skipL024
   1883  f52f    junk
   1884  f52f        b6 a0 00 00       .byte.b $B6,$A0,0,0
   1885  f533
   1886  f533        b4 a1 00 00       .byte.b $B4,$A1,0,0
   1887  f537
   1888  f537        b4 a2 00 00       .byte.b $B4,$A2,0,0
   1889  f53b
   1890  f53b        c4 a3 00 00       .byte.b $C4,$A3,0,0
   1891  f53f
   1892  f53f        c4 a4 00 00       .byte.b $C4,$A4,0,0
   1893  f543
   1894  f543        d4 a5 00 00       .byte.b $D4,$A5,0,0
   1895  f547
   1896  f547        d4 a6 00 00       .byte.b $D4,$A6,0,0
   1897  f54b
   1898  f54b        e4 a7 00 00       .byte.b $E4,$A7,0,0
   1899  f54f
   1900  f54f        e4 a8 00 00       .byte.b $E4,$A8,0,0
   1901  f553
   1902  f553        f4 a9 00 00       .byte.b $F4,$A9,0,0
   1903  f557
   1904  f557        f4 aa 00 00       .byte.b $F4,$AA,0,0
   1905  f55b
   1906  f55b        24 ab 00 00       .byte.b $24,$AB,0,0
   1907  f55f
   1908  f55f        24 ac 00 00       .byte.b $24,$AC,0,0
   1909  f563
   1910  f563        34 ad 00 00       .byte.b $34,$AD,0,0
   1911  f567
   1912  f567        34 ae 00 00       .byte.b $34,$AE,0,0
   1913  f56b
   1914  f56b        44 af 00 00       .byte.b $44,$AF,0,0
   1915  f56f
   1916  f56f        44 b0 00 00       .byte.b $44,$B0,0,0
   1917  f573
   1918  f573        54 b1 00 00       .byte.b $54,$B1,0,0
   1919  f577
   1920  f577        54 b2 00 00       .byte.b $54,$B2,0,0
   1921  f57b
   1922  f57b        64 b3 00 00       .byte.b $64,$B3,0,0
   1923  f57f
   1924  f57f        64 b4 00 00       .byte.b $64,$B4,0,0
   1925  f583
   1926  f583        74 b5 00 00       .byte.b $74,$B5,0,0
   1927  f587
   1928  f587        74 b6 00 00       .byte.b $74,$B6,0,0
   1929  f58b
   1930  f58b        84 b7 00 00       .byte.b $84,$B7,0,0
   1931  f58f
   1932  f58f        84 b8 00 00       .byte.b $84,$B8,0,0
   1933  f593
   1934  f593        86 b9 00 00       .byte.b $86,$B9,0,0
   1935  f597
   1936  f597        86 ba 00 00       .byte.b $86,$BA,0,0
   1937  f59b
   1938  f59b        88 bc 00 00       .byte.b $88,$BC,0,0
   1939  f59f
   1940  f59f        88 bd 00 00       .byte.b $88,$BD,0,0
   1941  f5a3
   1942  f5a3        8a be 00 00       .byte.b $8A,$BE,0,0
   1943  f5a7
   1944  f5a7        8a bf 00 00       .byte.b $8A,$BF,0,0
   1945  f5ab
   1946  f5ab        8c c0 00 00       .byte.b $8C,$C0,0,0
   1947  f5af
   1948  f5af        8c c1 00 00       .byte.b $8C,$C1,0,0
   1949  f5b3
   1950  f5b3        8e c2 00 00       .byte.b $8E,$C2,0,0
   1951  f5b7
   1952  f5b7        8e c3 00 00       .byte.b $8E,$C3,0,0
   1953  f5bb
   1954  f5bb    .skipL024
   1955  f5bb    .
   1956  f5bb ;
   1957  f5bb
   1958  f5bb    .
   1959  f5bb ;
   1960  f5bb
   1961  f5bb    .L025 ;  rem the rest of the code
   1962  f5bb
   1963  f5bb    .L026 ;  rem
   1964  f5bb
   1965  f5bb    .L027 ;  rem
   1966  f5bb
   1967  f5bb    .L028 ;  rem
   1968  f5bb
   1969  f5bb    .L029 ;  rem
   1970  f5bb
   1971  f5bb   -       ifconst pfres
   1972  f5bb   -       if (<*) > (254-pfres*pfwidth)
   1973  f5bb   -       align 256
   1974  f5bb   -       endif
   1975  f5bb   -       if (<*) < (136-pfres*pfwidth)
   1976  f5bb   -       repeat ((136-pfres*pfwidth)-(<*))
   1977  f5bb   -       .byte 0
   1978  f5bb   -       repend
   1979  f5bb   -       endif
   1980  f5bb       else
   1981  f5bb   -       if (<*) > 206
   1982  f5bb   -       align 256
   1983  f5bb       endif
   1984  f5bb   -       if (<*) < 88
   1985  f5bb   -       repeat (88-(<*))
   1986  f5bb   -       .byte 0
   1987  f5bb   -       repend
   1988  f5bb       endif
   1989  f5bb       endif
   1990  f5bb    pfcolorlabel13
   1991  f5bb        b6 a1 00 00       .byte.b $B6, $A1,0,0
   1992  f5bf        b4 a2 00 00       .byte.b $B4, $A2,0,0
   1993  f5c3        b4 a3 00 00       .byte.b $B4, $A3,0,0
   1994  f5c7        c4 a4 00 00       .byte.b $C4, $A4,0,0
   1995  f5cb        c4 a5 00 00       .byte.b $C4, $A5,0,0
   1996  f5cf        d4 a6 00 00       .byte.b $D4, $A6,0,0
   1997  f5d3        d4 a7 00 00       .byte.b $D4, $A7,0,0
   1998  f5d7        e4 a8 00 00       .byte.b $E4, $A8,0,0
   1999  f5db        e4 a9 00 00       .byte.b $E4, $A9,0,0
   2000  f5df        f4 aa 00 00       .byte.b $F4, $AA,0,0
   2001  f5e3        f4 ab 00 00       .byte.b $F4, $AB,0,0
   2002  f5e7        24 ac 00 00       .byte.b $24, $AC,0,0
   2003  f5eb        24 ad 00 00       .byte.b $24, $AD,0,0
   2004  f5ef        34 ae 00 00       .byte.b $34, $AE,0,0
   2005  f5f3        34 af 00 00       .byte.b $34, $AF,0,0
   2006  f5f7        44 b0 00 00       .byte.b $44, $B0,0,0
   2007  f5fb        44 b1 00 00       .byte.b $44, $B1,0,0
   2008  f5ff        54 b2 00 00       .byte.b $54, $B2,0,0
   2009  f603        54 b3 00 00       .byte.b $54, $B3,0,0
   2010  f607        64 b4 00 00       .byte.b $64, $B4,0,0
   2011  f60b        64 b5 00 00       .byte.b $64, $B5,0,0
   2012  f60f        74 b6 00 00       .byte.b $74, $B6,0,0
   2013  f613        74 b7 00 00       .byte.b $74, $B7,0,0
   2014  f617        84 b8 00 00       .byte.b $84, $B8,0,0
   2015  f61b        84 b9 00 00       .byte.b $84, $B9,0,0
   2016  f61f        86 bb 00 00       .byte.b $86, $BB,0,0
   2017  f623        86 ba 00 00       .byte.b $86, $BA,0,0
   2018  f627        88 bc 00 00       .byte.b $88, $BC,0,0
   2019  f62b        88 bd 00 00       .byte.b $88, $BD,0,0
   2020  f62f        8a be 00 00       .byte.b $8A, $BE,0,0
   2021  f633        8a bf 00 00       .byte.b $8A, $BF,0,0
   2022  f637        8c c0 00 00       .byte.b $8C, $C0,0,0
   2023  f63b        8c c1 00 00       .byte.b $8C, $C1,0,0
   2024  f63f        8e c2 00 00       .byte.b $8E, $C2,0,0
   2025  f643        8e c3 00 00       .byte.b $8E, $C3,0,0
   2026  f647       if ECHOFIRST
      2389 bytes of ROM space left
 

 

Edited by bogax
Link to comment
Share on other sites

 

 

Here I've taken your code and altered it to illustrate some stuff, mostly why you need the .lst file

 

I added another pfcolors statement so you can see what happens

 

I added some Bb equivalents to the pfcolors statements (that refer to the table Bb produces)

 

I added a data statement with the table (same data) called my_pfcolors_table

 

The junk data is just to push Bb's pfcolors table across a page boundary

(I used the my_pfcolors_table data. In retrospect, I should have used something completely

different to set it apart)

 

The rem statements at the end are just to mark the end of the Bb code in the .lst file

 

I've only included the pertinent part of the .list file (well, some. it doesn't show why Bb does

what it does)

 

this compiles but is UNTESTED (and it doesn't do anything)

 set kernel_options pfcolors

 
 
 dim pfcolortable_lo = pfcolortable
 dim pfcolortable_hi = pfcolortable + 1
 
 
 rem  this just gives a name to use that wont change if
 rem  the label pfcolorlabel3 between compiles
 
 const Bb_pfcolor_table_01 = pfcolorlabel13-84
 
 const Colors1A_lo = <Bb_pfcolor_table_01
 const Colors1A_hi = >Bb_pfcolor_table_01
 
 
Level1ColorsA
 pfcolors:
 $B6
 $B6
 $B4
 $B4
 $C4
 $C4
 $D4
 $D4
 $E4
 $E4
 $F4
 $F4
 $24
 $24
 $34
 $34
 $44
 $44
 $54
 $54
 $64
 $64
 $74
 $74
 $84
 $84
 $86
 $86
 $88
 $88
 $8A
 $8A
 $8C
 $8C
 $8E
 $8E
end
 
 COLUPF = $B6
 pfcolortable_hi = Colors1A_hi
 pfcolortable_lo = Colors1A_lo
 
 
More_pfcolors
 pfcolors:
 $A0
 $A1
 $A2
 $A3
 $A4
 $A5
 $A6
 $A7
 $A8
 $A9
 $AA
 $AB
 $AC
 $AD
 $AE
 $AF
 $B0
 $B1
 $B2
 $B3
 $B4
 $B5
 $B6
 $B7
 $B8
 $B9
 $BB
 $BA
 $BC
 $BD
 $BE
 $BF
 $C0
 $C1
 $C2
 $C3
end
 
 
 const More_pfcolors_lo = <(Bb_pfcolor_table_01 + 1)
 const More_pfcolors_hi = >(Bb_pfcolor_table_01 + 1)
 
 
 COLUPF = $A0
 pfcolortable_hi = More_pfcolors_hi
 pfcolortable_lo = More_pfcolors_lo
 
 
 
 const my_colors_lo = <(my_pfcolors_table - 84)
 const my_colors_hi = >(my_pfcolors_table - 84)
 
 
 data my_pfcolors_table
 $B6,$A0,0,0
 $B4,$A1,0,0
 $B4,$A2,0,0
 $C4,$A3,0,0
 $C4,$A4,0,0
 $D4,$A5,0,0
 $D4,$A6,0,0
 $E4,$A7,0,0
 $E4,$A8,0,0
 $F4,$A9,0,0
 $F4,$AA,0,0
 $24,$AB,0,0
 $24,$AC,0,0
 $34,$AD,0,0
 $34,$AE,0,0
 $44,$AF,0,0
 $44,$B0,0,0
 $54,$B1,0,0
 $54,$B2,0,0
 $64,$B3,0,0
 $64,$B4,0,0
 $74,$B5,0,0
 $74,$B6,0,0
 $84,$B7,0,0
 $84,$B8,0,0
 $86,$B9,0,0
 $86,$BA,0,0
 $88,$BC,0,0
 $88,$BD,0,0
 $8A,$BE,0,0
 $8A,$BF,0,0
 $8C,$C0,0,0
 $8C,$C1,0,0
 $8E,$C2,0,0
 $8E,$C3,0,0
end
 
 COLUPF = my_pfcolors_table[0]
 
 pfcolortable_lo = my_colors_lo
 pfcolortable_hi = my_colors_hi
 
 
 data junk
 $B6,$A0,0,0
 $B4,$A1,0,0
 $B4,$A2,0,0
 $C4,$A3,0,0
 $C4,$A4,0,0
 $D4,$A5,0,0
 $D4,$A6,0,0
 $E4,$A7,0,0
 $E4,$A8,0,0
 $F4,$A9,0,0
 $F4,$AA,0,0
 $24,$AB,0,0
 $24,$AC,0,0
 $34,$AD,0,0
 $34,$AE,0,0
 $44,$AF,0,0
 $44,$B0,0,0
 $54,$B1,0,0
 $54,$B2,0,0
 $64,$B3,0,0
 $64,$B4,0,0
 $74,$B5,0,0
 $74,$B6,0,0
 $84,$B7,0,0
 $84,$B8,0,0
 $86,$B9,0,0
 $86,$BA,0,0
 $88,$BC,0,0
 $88,$BD,0,0
 $8A,$BE,0,0
 $8A,$BF,0,0
 $8C,$C0,0,0
 $8C,$C1,0,0
 $8E,$C2,0,0
 $8E,$C3,0,0
end
 
 
 rem the rest of the code
 rem
 rem
 rem
 rem
 
   1634  f45e    .L00  ;  set kernel_options pfcolors


   1635  f45e
   1636  f45e    .
   1637  f45e ;
   1638  f45e
   1639  f45e    .
   1640  f45e ;
   1641  f45e
   1642  f45e    .L01  ;  dim pfcolortable_lo  =  pfcolortable
   1643  f45e
   1644  f45e    .L02  ;  dim pfcolortable_hi  =  pfcolortable  +  1
   1645  f45e
   1646  f45e    .
   1647  f45e ;
   1648  f45e
   1649  f45e    .
   1650  f45e ;
   1651  f45e
   1652  f45e    .L03  ;  rem  this just gives a name to use that wont change if
   1653  f45e
   1654  f45e    .L04  ;  rem  the label pfcolorlabel3 between compiles
   1655  f45e
   1656  f45e    .
   1657  f45e ;
   1658  f45e
   1659  f45e    .L05  ;  const Bb_pfcolor_table_01  =  pfcolorlabel13 - 84
   1660  f45e
   1661  f45e    .
   1662  f45e ;
   1663  f45e
   1664  f45e    .L06  ;  const Colors1A_lo  =   < Bb_pfcolor_table_01
   1665  f45e
   1666  f45e    .L07  ;  const Colors1A_hi  =   > Bb_pfcolor_table_01
   1667  f45e
   1668  f45e    .
   1669  f45e ;
   1670  f45e
   1671  f45e    .
   1672  f45e ;
   1673  f45e
   1674  f45e    .Level1ColorsA
   1675  f45e ; Level1ColorsA
   1676  f45e
   1677  f45e    .L08  ;  pfcolors:
   1678  f45e
   1679  f45e        a9 b6       lda # $B6
   1680  f460        85 08       sta COLUPF
   1681  f462   -       ifconst pfres
   1682  f462   -       lda #>(pfcolorlabel13-132+pfres*pfwidth)
   1683  f462       else
   1684  f462        a9 f5       lda #>(pfcolorlabel13-84)
   1685  f464       endif
   1686  f464        85 f1       sta pfcolortable+1
   1687  f466   -       ifconst pfres
   1688  f466   -       lda #<(pfcolorlabel13-132+pfres*pfwidth)
   1689  f466       else
   1690  f466        a9 67       lda #<(pfcolorlabel13-84)
   1691  f468       endif
   1692  f468        85 f0       sta pfcolortable
   1693  f46a    .
   1694  f46a ;
   1695  f46a
   1696  f46a    .L09  ;  COLUPF  =  $B6
   1697  f46a
   1698  f46a        a9 b6       LDA #$B6
   1699  f46c        85 08       STA COLUPF
   1700  f46e    .L010 ;  pfcolortable_hi  = Colors1A_hi
   1701  f46e
   1702  f46e        a9 f5       LDA #Colors1A_hi
   1703  f470        85 f1       STA pfcolortable_hi
   1704  f472    .L011 ;  pfcolortable_lo  = Colors1A_lo
   1705  f472
   1706  f472        a9 67       LDA #Colors1A_lo
   1707  f474        85 f0       STA pfcolortable_lo
   1708  f476    .
   1709  f476 ;
   1710  f476
   1711  f476    .
   1712  f476 ;
   1713  f476
   1714  f476    .More_pfcolors
   1715  f476 ; More_pfcolors
   1716  f476
   1717  f476    .L012 ;  pfcolors:
   1718  f476
   1719  f476        a9 a0       lda # $A0
   1720  f478        85 08       sta COLUPF
   1721  f47a   -       ifconst pfres
   1722  f47a   -       lda #>(pfcolorlabel13-131+pfres*pfwidth)
   1723  f47a       else
   1724  f47a        a9 f5       lda #>(pfcolorlabel13-83)
   1725  f47c       endif
   1726  f47c        85 f1       sta pfcolortable+1
   1727  f47e   -       ifconst pfres
   1728  f47e   -       lda #<(pfcolorlabel13-131+pfres*pfwidth)
   1729  f47e       else
   1730  f47e        a9 68       lda #<(pfcolorlabel13-83)
   1731  f480       endif
   1732  f480        85 f0       sta pfcolortable
   1733  f482    .
   1734  f482 ;
   1735  f482
   1736  f482    .
   1737  f482 ;
   1738  f482
   1739  f482    .L013 ;  const More_pfcolors_lo  = <  ( Bb_pfcolor_table_01  +  1 )
   1740  f482
   1741  f482    .L014 ;  const More_pfcolors_hi  = >  ( Bb_pfcolor_table_01  +  1 )
   1742  f482
   1743  f482    .
   1744  f482 ;
   1745  f482
   1746  f482    .
   1747  f482 ;
   1748  f482
   1749  f482    .L015 ;  COLUPF  =  $A0
   1750  f482
   1751  f482        a9 a0       LDA #$A0
   1752  f484        85 08       STA COLUPF
   1753  f486    .L016 ;  pfcolortable_hi  = More_pfcolors_hi
   1754  f486
   1755  f486        a9 f5       LDA #More_pfcolors_hi
   1756  f488        85 f1       STA pfcolortable_hi
   1757  f48a    .L017 ;  pfcolortable_lo  = More_pfcolors_lo
   1758  f48a
   1759  f48a        a9 68       LDA #More_pfcolors_lo
   1760  f48c        85 f0       STA pfcolortable_lo
   1761  f48e    .
   1762  f48e ;
   1763  f48e
   1764  f48e    .
   1765  f48e ;
   1766  f48e
   1767  f48e    .
   1768  f48e ;
   1769  f48e
   1770  f48e    .L018 ;  const my_colors_lo =   <  ( my_pfcolors_table  -  84 )
   1771  f48e
   1772  f48e    .L019 ;  const my_colors_hi =   >  ( my_pfcolors_table  -  84 )
   1773  f48e
   1774  f48e    .
   1775  f48e ;
   1776  f48e
   1777  f48e    .
   1778  f48e ;
   1779  f48e
   1780  f48e    .L020 ;  data my_pfcolors_table
   1781  f48e
   1782  f48e        4c 1d f5        JMP .skipL020
   1783  f491    my_pfcolors_table
   1784  f491        b6 a0 00 00       .byte.b $B6,$A0,0,0
   1785  f495
   1786  f495        b4 a1 00 00       .byte.b $B4,$A1,0,0
   1787  f499
   1788  f499        b4 a2 00 00       .byte.b $B4,$A2,0,0
   1789  f49d
   1790  f49d        c4 a3 00 00       .byte.b $C4,$A3,0,0
   1791  f4a1
   1792  f4a1        c4 a4 00 00       .byte.b $C4,$A4,0,0
   1793  f4a5
   1794  f4a5        d4 a5 00 00       .byte.b $D4,$A5,0,0
   1795  f4a9
   1796  f4a9        d4 a6 00 00       .byte.b $D4,$A6,0,0
   1797  f4ad
   1798  f4ad        e4 a7 00 00       .byte.b $E4,$A7,0,0
   1799  f4b1
   1800  f4b1        e4 a8 00 00       .byte.b $E4,$A8,0,0
   1801  f4b5
   1802  f4b5        f4 a9 00 00       .byte.b $F4,$A9,0,0
   1803  f4b9
   1804  f4b9        f4 aa 00 00       .byte.b $F4,$AA,0,0
   1805  f4bd
   1806  f4bd        24 ab 00 00       .byte.b $24,$AB,0,0
   1807  f4c1
   1808  f4c1        24 ac 00 00       .byte.b $24,$AC,0,0
   1809  f4c5
   1810  f4c5        34 ad 00 00       .byte.b $34,$AD,0,0
   1811  f4c9
   1812  f4c9        34 ae 00 00       .byte.b $34,$AE,0,0
   1813  f4cd
   1814  f4cd        44 af 00 00       .byte.b $44,$AF,0,0
   1815  f4d1
   1816  f4d1        44 b0 00 00       .byte.b $44,$B0,0,0
   1817  f4d5
   1818  f4d5        54 b1 00 00       .byte.b $54,$B1,0,0
   1819  f4d9
   1820  f4d9        54 b2 00 00       .byte.b $54,$B2,0,0
   1821  f4dd
   1822  f4dd        64 b3 00 00       .byte.b $64,$B3,0,0
   1823  f4e1
   1824  f4e1        64 b4 00 00       .byte.b $64,$B4,0,0
   1825  f4e5
   1826  f4e5        74 b5 00 00       .byte.b $74,$B5,0,0
   1827  f4e9
   1828  f4e9        74 b6 00 00       .byte.b $74,$B6,0,0
   1829  f4ed
   1830  f4ed        84 b7 00 00       .byte.b $84,$B7,0,0
   1831  f4f1
   1832  f4f1        84 b8 00 00       .byte.b $84,$B8,0,0
   1833  f4f5
   1834  f4f5        86 b9 00 00       .byte.b $86,$B9,0,0
   1835  f4f9
   1836  f4f9        86 ba 00 00       .byte.b $86,$BA,0,0
   1837  f4fd
   1838  f4fd        88 bc 00 00       .byte.b $88,$BC,0,0
   1839  f501
   1840  f501        88 bd 00 00       .byte.b $88,$BD,0,0
   1841  f505
   1842  f505        8a be 00 00       .byte.b $8A,$BE,0,0
   1843  f509
   1844  f509        8a bf 00 00       .byte.b $8A,$BF,0,0
   1845  f50d
   1846  f50d        8c c0 00 00       .byte.b $8C,$C0,0,0
   1847  f511
   1848  f511        8c c1 00 00       .byte.b $8C,$C1,0,0
   1849  f515
   1850  f515        8e c2 00 00       .byte.b $8E,$C2,0,0
   1851  f519
   1852  f519        8e c3 00 00       .byte.b $8E,$C3,0,0
   1853  f51d
   1854  f51d    .skipL020
   1855  f51d    .
   1856  f51d ;
   1857  f51d
   1858  f51d    .L021 ;  COLUPF  =  my_pfcolors_table[0]
   1859  f51d
   1860  f51d        a2 00       LDX #0
   1861  f51f        bd 91 f4        LDA my_pfcolors_table,x
   1862  f522        85 08       STA COLUPF
   1863  f524    .
   1864  f524 ;
   1865  f524
   1866  f524    .L022 ;  pfcolortable_lo  = my_colors_lo
   1867  f524
   1868  f524        a9 3d       LDA #my_colors_lo
   1869  f526        85 f0       STA pfcolortable_lo
   1870  f528    .L023 ;  pfcolortable_hi  = my_colors_hi
   1871  f528
   1872  f528        a9 f4       LDA #my_colors_hi
   1873  f52a        85 f1       STA pfcolortable_hi
   1874  f52c    .
   1875  f52c ;
   1876  f52c
   1877  f52c    .
   1878  f52c ;
   1879  f52c
   1880  f52c    .L024 ;  data junk
   1881  f52c
   1882  f52c        4c bb f5        JMP .skipL024
   1883  f52f    junk
   1884  f52f        b6 a0 00 00       .byte.b $B6,$A0,0,0
   1885  f533
   1886  f533        b4 a1 00 00       .byte.b $B4,$A1,0,0
   1887  f537
   1888  f537        b4 a2 00 00       .byte.b $B4,$A2,0,0
   1889  f53b
   1890  f53b        c4 a3 00 00       .byte.b $C4,$A3,0,0
   1891  f53f
   1892  f53f        c4 a4 00 00       .byte.b $C4,$A4,0,0
   1893  f543
   1894  f543        d4 a5 00 00       .byte.b $D4,$A5,0,0
   1895  f547
   1896  f547        d4 a6 00 00       .byte.b $D4,$A6,0,0
   1897  f54b
   1898  f54b        e4 a7 00 00       .byte.b $E4,$A7,0,0
   1899  f54f
   1900  f54f        e4 a8 00 00       .byte.b $E4,$A8,0,0
   1901  f553
   1902  f553        f4 a9 00 00       .byte.b $F4,$A9,0,0
   1903  f557
   1904  f557        f4 aa 00 00       .byte.b $F4,$AA,0,0
   1905  f55b
   1906  f55b        24 ab 00 00       .byte.b $24,$AB,0,0
   1907  f55f
   1908  f55f        24 ac 00 00       .byte.b $24,$AC,0,0
   1909  f563
   1910  f563        34 ad 00 00       .byte.b $34,$AD,0,0
   1911  f567
   1912  f567        34 ae 00 00       .byte.b $34,$AE,0,0
   1913  f56b
   1914  f56b        44 af 00 00       .byte.b $44,$AF,0,0
   1915  f56f
   1916  f56f        44 b0 00 00       .byte.b $44,$B0,0,0
   1917  f573
   1918  f573        54 b1 00 00       .byte.b $54,$B1,0,0
   1919  f577
   1920  f577        54 b2 00 00       .byte.b $54,$B2,0,0
   1921  f57b
   1922  f57b        64 b3 00 00       .byte.b $64,$B3,0,0
   1923  f57f
   1924  f57f        64 b4 00 00       .byte.b $64,$B4,0,0
   1925  f583
   1926  f583        74 b5 00 00       .byte.b $74,$B5,0,0
   1927  f587
   1928  f587        74 b6 00 00       .byte.b $74,$B6,0,0
   1929  f58b
   1930  f58b        84 b7 00 00       .byte.b $84,$B7,0,0
   1931  f58f
   1932  f58f        84 b8 00 00       .byte.b $84,$B8,0,0
   1933  f593
   1934  f593        86 b9 00 00       .byte.b $86,$B9,0,0
   1935  f597
   1936  f597        86 ba 00 00       .byte.b $86,$BA,0,0
   1937  f59b
   1938  f59b        88 bc 00 00       .byte.b $88,$BC,0,0
   1939  f59f
   1940  f59f        88 bd 00 00       .byte.b $88,$BD,0,0
   1941  f5a3
   1942  f5a3        8a be 00 00       .byte.b $8A,$BE,0,0
   1943  f5a7
   1944  f5a7        8a bf 00 00       .byte.b $8A,$BF,0,0
   1945  f5ab
   1946  f5ab        8c c0 00 00       .byte.b $8C,$C0,0,0
   1947  f5af
   1948  f5af        8c c1 00 00       .byte.b $8C,$C1,0,0
   1949  f5b3
   1950  f5b3        8e c2 00 00       .byte.b $8E,$C2,0,0
   1951  f5b7
   1952  f5b7        8e c3 00 00       .byte.b $8E,$C3,0,0
   1953  f5bb
   1954  f5bb    .skipL024
   1955  f5bb    .
   1956  f5bb ;
   1957  f5bb
   1958  f5bb    .
   1959  f5bb ;
   1960  f5bb
   1961  f5bb    .L025 ;  rem the rest of the code
   1962  f5bb
   1963  f5bb    .L026 ;  rem
   1964  f5bb
   1965  f5bb    .L027 ;  rem
   1966  f5bb
   1967  f5bb    .L028 ;  rem
   1968  f5bb
   1969  f5bb    .L029 ;  rem
   1970  f5bb
   1971  f5bb   -       ifconst pfres
   1972  f5bb   -       if (<*) > (254-pfres*pfwidth)
   1973  f5bb   -       align 256
   1974  f5bb   -       endif
   1975  f5bb   -       if (<*) < (136-pfres*pfwidth)
   1976  f5bb   -       repeat ((136-pfres*pfwidth)-(<*))
   1977  f5bb   -       .byte 0
   1978  f5bb   -       repend
   1979  f5bb   -       endif
   1980  f5bb       else
   1981  f5bb   -       if (<*) > 206
   1982  f5bb   -       align 256
   1983  f5bb       endif
   1984  f5bb   -       if (<*) < 88
   1985  f5bb   -       repeat (88-(<*))
   1986  f5bb   -       .byte 0
   1987  f5bb   -       repend
   1988  f5bb       endif
   1989  f5bb       endif
   1990  f5bb    pfcolorlabel13
   1991  f5bb        b6 a1 00 00       .byte.b $B6, $A1,0,0
   1992  f5bf        b4 a2 00 00       .byte.b $B4, $A2,0,0
   1993  f5c3        b4 a3 00 00       .byte.b $B4, $A3,0,0
   1994  f5c7        c4 a4 00 00       .byte.b $C4, $A4,0,0
   1995  f5cb        c4 a5 00 00       .byte.b $C4, $A5,0,0
   1996  f5cf        d4 a6 00 00       .byte.b $D4, $A6,0,0
   1997  f5d3        d4 a7 00 00       .byte.b $D4, $A7,0,0
   1998  f5d7        e4 a8 00 00       .byte.b $E4, $A8,0,0
   1999  f5db        e4 a9 00 00       .byte.b $E4, $A9,0,0
   2000  f5df        f4 aa 00 00       .byte.b $F4, $AA,0,0
   2001  f5e3        f4 ab 00 00       .byte.b $F4, $AB,0,0
   2002  f5e7        24 ac 00 00       .byte.b $24, $AC,0,0
   2003  f5eb        24 ad 00 00       .byte.b $24, $AD,0,0
   2004  f5ef        34 ae 00 00       .byte.b $34, $AE,0,0
   2005  f5f3        34 af 00 00       .byte.b $34, $AF,0,0
   2006  f5f7        44 b0 00 00       .byte.b $44, $B0,0,0
   2007  f5fb        44 b1 00 00       .byte.b $44, $B1,0,0
   2008  f5ff        54 b2 00 00       .byte.b $54, $B2,0,0
   2009  f603        54 b3 00 00       .byte.b $54, $B3,0,0
   2010  f607        64 b4 00 00       .byte.b $64, $B4,0,0
   2011  f60b        64 b5 00 00       .byte.b $64, $B5,0,0
   2012  f60f        74 b6 00 00       .byte.b $74, $B6,0,0
   2013  f613        74 b7 00 00       .byte.b $74, $B7,0,0
   2014  f617        84 b8 00 00       .byte.b $84, $B8,0,0
   2015  f61b        84 b9 00 00       .byte.b $84, $B9,0,0
   2016  f61f        86 bb 00 00       .byte.b $86, $BB,0,0
   2017  f623        86 ba 00 00       .byte.b $86, $BA,0,0
   2018  f627        88 bc 00 00       .byte.b $88, $BC,0,0
   2019  f62b        88 bd 00 00       .byte.b $88, $BD,0,0
   2020  f62f        8a be 00 00       .byte.b $8A, $BE,0,0
   2021  f633        8a bf 00 00       .byte.b $8A, $BF,0,0
   2022  f637        8c c0 00 00       .byte.b $8C, $C0,0,0
   2023  f63b        8c c1 00 00       .byte.b $8C, $C1,0,0
   2024  f63f        8e c2 00 00       .byte.b $8E, $C2,0,0
   2025  f643        8e c3 00 00       .byte.b $8E, $C3,0,0
   2026  f647       if ECHOFIRST
      2389 bytes of ROM space left
 

 

Wow, did not expect such a response. This is a lot of info to play with. I tried doing some testing with just the pfcolortable variable in its own program file in both a 4K and 32K program and I got it to work just like I wanted to by just subtracting or adding 4 every time I wanted to scroll the colors. However when applying the same functionality to my main program it would do totally funky things with the colors. I'm guessing it was because I have so much more going on in my main program that it's placing tables and locations in different part of the code rather than what it is doing in my lesser pfcolortable test program. I didn't post my entire code because well....it's 32K right now. There's a ton of crap in there that has nothing to do with color scrolling and so I condensed my post here to the parts that had to do with the color scrolling. I didn't even think about checking (or posting) the lst file. I'll be sure to do that in the future and now that I have what you posted, it gives me a lot more to play around with to maybe get this working (along with checking the lst). Thanks for your help and info on that. I'll play with it again sometime in the near future. Since this post, I've moved on to other parts of the program and am not ready to return back to color scrolling just yet.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...




Here's some code that scrolls the playfield colors up.


It keeps a frame counter and advances by one color by adding 4 to pfcolortable

(the color table pointer which I called pfcolor_pointer in Bb) whenever the lowest

4 bits of the frame counter = 0 (so every 16 frames ~1/4 second)

It adds 4 to the pfcolor_pointer because the colors are every 4th entry in the table


When its scrolled up by 24 colors it subtracts 24 x 4 (96) from pfcolortable

That is, the 24th sets the pointer back to the beginning of the table)


pfcolor_pointer = pfcolor_pointer - 0.375 (0.375 is 96, see below)



It maintains color_number in parallel to keep track of where it is in the colors

rather than messing with pfcolortable in the if statement predicate



tmp and pfcolor_pointer are 8.8 Bb variables (since we're messing with 16 bit pointers)


Constants (like the above mentioned 96) need to be expressed in that format so it's

96 / 256 rounded up to three decimal places ie


pfcolor_pointer = pfcolor_pointer - 0.375


likewise, 4 is 0.016 in 8.8 format



The pfcolors in the pfcolors statement are 24 colors followed by the first 10 repeated

(the last screen is the first screen offset by 1 color, and there's 11 colors per screen)


Now I'm guessing it's a bug in the kernel or I may have goofed something but the

kernel only displays 10 lines of color, skipping the first line.

so the color of the first line of playfield has to be set in the main loop (thats normal)

and pfcolortable has to be offset by 1 color


The pfcolors statement sets pfcolortable (the variable which I'm calling pfcolor_pointer in Bb)

to the location of the pfcolors table - 84 (I didn't try to figure out why)


tmp is used as a pointer to get the first color (with a dab of asm) in the first_color function.

The location of tmp ($9E) is passed to the first_color function and it returns the byte pointed to by tmp.

tmp is first set to pfcolor_pointer + 84 - 4


tmp = pfcolor_pointer + 0.313



The compiler complains about an extraneous end statement but I'm guessing that's a bug

in the parsing evoked due to using the asm statement in a function


edit: my bad. a function doesn't need an end statement, it just needs to return


The code produced seems correct



no doubt the numbers would change with different numbers of colors or different kernel options/paramters, etc







set kernel_options pfcolors

pfcolors:
$16
$1E
$26
$2E
$36
$3E
$46
$4E
$56
$66
$6E
$76
$7E
$86
$8E
$96
$9E
$AE
$B6
$BE
$C6
$CE
$D6
$DE
$16
$1E
$26
$2E
$36
$3E
$46
$4E
$56
$66
end


rem name the 16 bit variables used for pointers

dim tmp = temp4.temp3
dim pfcolor_pointerlo = $F0
dim pfcolor_pointerhi = $F1
dim pfcolor_pointer = pfcolor_pointerhi.pfcolor_pointerlo


dim frame_counter = c
dim color_number = d


frame_counter = 0 : color_number = 0

playfield:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end


rem the kernel displays the 10 lines starting
rem with the second, so offset the pfcolor_pointer
rem to point to the color for the second line
rem by adding 4 to it which is 0.016 in 8.8 format
rem and the colors are every 4th entry in the
rem pfcolortable table

pfcolor_pointer = pfcolor_pointer + 0.016


loop
frame_counter = frame_counter + 1

if frame_counter & $0F then skip_scroll_pfcolors
color_number = color_number + 1 : pfcolor_pointer = pfcolor_pointer + 0.016

rem if we're at the end of the table go back to the beginning by subtracting
rem 24 x 4 from the pointer ie 0.375 in 8.8 format

if color_number = 24 then color_number = 0 : pfcolor_pointer = pfcolor_pointer - 0.375


skip_scroll_pfcolors

rem set the tmp pointer to the location of the color
rem of the first line

tmp = pfcolor_pointer + 0.313


COLUPF = first_color($9E)

drawscreen

goto loop

function first_color
asm
tax
lda (0,x)
rts
end
end




Edited by bogax
Link to comment
Share on other sites

  • 2 weeks later...

here's some code that puts the colors in a table in a data statement


conversion from color number to table index is done with another table


this is set up to step through the colors using joy0 up-down


color number is on the playfield on the third line from the bottom

the color table pointer is the second line from the bottom

the bottom is just to mark where the nibbles are





set kernel_options pfcolors

set optimization noinlinedata

dim pfcolor_pointerlo = $F0
dim pfcolor_pointerhi = $F1

const pfcolorslo = <(pfc_table - 84)
const pfcolorshi = >(pfc_table - 84)

dim color_number = d


playfield:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end


color_number = 27
pfcolor_pointerlo = pfcolorslo : pfcolor_pointerhi = pfcolorshi


loop

temp1 = (SWCHA ^ $FF) & f : f = SWCHA

if !temp1 then skip_scroll_pfcolors

if temp1{4} then color_number = color_number + 1 : if color_number = 28 then color_number = 0
if temp1{5} then color_number = color_number - 1 : if color_number = $FF then color_number = 27
temp1 = color_number + 1 : if temp1 = 28 then temp1 = 0
pfcolor_pointerlo = pfcidx[temp1] + pfcolorslo


skip_scroll_pfcolors


temp1 = pfcidx[color_number] : COLUPF = pfc_table[temp1]

var29 = rev(pfcolorslo)
var33 = rev(color_number)
var40 = $F0 : var41 = $0F
var36 = pfcolor_pointerhi
var37 = rev(pfcolor_pointerlo)

drawscreen

goto loop


function rev()
temp2 = temp1 & $0F
temp1 = temp1 / 16
temp1 = revlo[temp2] * 16 | revlo[temp1]
return

data revlo
$00, $08, $04, $0C, $02, $0A, $06, $0E
$01, $09, $05, $0D, $03, $0B, $07, $0F
end


data pfc_table
$02, $DE, $2E, $E6
$36, $BE, $4E, $C6
$56, $9E, $6E, $A6
$76, $7E, $8E, $86
$96, $5E, $AE, $66
$B6, $3E, $CE, $46
$D6, $1E, $EE, $26
$DE, $2E, $E6, $02
$BE, $4E, $C6, $36
$9E, $6E, $A6, $56
$7E, $8E, $86, $76
$5E, $AE, $66, $96
$3E, $CE, $46, $B6
$1E, $EE, $26, $D6
$2E, $E6, $02, $DE
$4E, $C6, $36, $BE
$6E, $A6, $56, $9E
end


data pfcidx
$00, $04, $08, $0C, $10, $14, $18
$01, $05, $09, $0D, $11, $15, $19
$02, $06, $0A, $0E, $12, $16, $1A
$03, $07, $0B, $0F, $13, $17, $1B
end


Link to comment
Share on other sites



Here's a slightly different version with the pfcolor data (still) in a data statement.


color_number is now just the index into the playfield color data table and still gets

looked up with another table.


there's a line with a value that's ORed with $00.


if temp6{4} then color_number = nextc[color_number] : temp5 = $00 | nextc[color_number]

apparently Bb optimizes out the second loading of the index (presumably because it's the same name)

the ORing with $00 is just a minimal code way of preventing that (but not minimum, I could have

rearranged the code and done away with the OR)


I kludged in a minikernel to display the pointer and color_number in hex

pfcolortable is on the left and color_number is on the right



I should have mentioned that the pfcolor data table needs the correct page alignment

the only thing I did to accomodate that is the order of the data statements




set kernel_options pfcolors
set optimization noinlinedata

dim pfcolor_pointerlo = $F0
dim pfcolor_pointerhi = $F1
dim current_color = c
dim color_number = d

const pfcolorslo = <(pfc_table - 84)
const pfcolorshi = >(pfc_table - 84)

playfield:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end

color_number = 0 : current_color = pfc_table[color_number]
pfcolor_pointerlo = pfcolorslo + 4 : pfcolor_pointerhi = pfcolorshi


loop

temp6 = ((SWCHA ^ $FF) & f) & $30 : f = SWCHA

if !temp6 then skip_scroll_pfcolors

if temp6{4} then color_number = nextc[color_number] : temp5 = $00 | nextc[color_number]
if temp6{5} then temp5 = color_number : color_number = prevc[color_number]
pfcolor_pointerlo = temp5 + pfcolorslo : current_color = pfc_table[color_number]

skip_scroll_pfcolors

scr0 = color_number
scr3 = pfcolor_pointerhi : scr2 = pfcolor_pointerlo

COLUPF = current_color

drawscreen

goto loop


function rev()
temp2 = temp1 & $0F
temp1 = temp1 / 16
temp1 = revlo[temp2] * 16 | revlo[temp1]
return

data revlo
$00, $08, $04, $0C, $02, $0A, $06, $0E
$01, $09, $05, $0D, $03, $0B, $07, $0F
end


const nextc = prevc + 8

data prevc
$1B, $18, $19, $1A, $00, $01, $02
$03
$04, $05, $06, $07, $08, $09, $0A
$0B, $0C, $0D, $0E, $0F, $10, $11
$12, $13, $14, $15, $16, $17, $18
$19, $1A, $1B, $01, $02, $03, $00
end


data pfc_table
$02, $DE, $2E, $E6
$36, $BE, $4E, $C6
$56, $9E, $6E, $A6
$76, $7E, $8E, $86
$96, $5E, $AE, $66
$B6, $3E, $CE, $46
$D6, $1E, $EE, $26
$DE, $2E, $E6, $02
$BE, $4E, $C6, $36
$9E, $6E, $A6, $56
$7E, $8E, $86, $76
$5E, $AE, $66, $96
$3E, $CE, $46, $B6
$1E, $EE, $26, $D6
$2E, $E6, $02, $DE
$4E, $C6, $36, $BE
$6E, $A6, $56, $9E
end



minikernel
const minikernel = .minikernel

dim scr2 = score
dim scr1 = score + 1
dim scr0 = score + 2
dim scr3 = var44
dim gr0tmp = var45

rem each digit has a pointer in to the table(s)
rem there are four bytes per line, numbered 3..0 from
rem left to right. each byte has a left and a right
rem digit so the pointer for the third digit from
rem the left is p2l and each pointer has a lo and a hi byte


dim p0llo = score + 3
dim p0lhi = score + 4
dim p1llo = score + 5
dim p1lhi = score + 6
dim p2llo = score + 7
dim p2lhi = score + 8
dim p3llo = temp1
dim p3lhi = temp2
dim p0rlo = temp3
dim p0rhi = temp4
dim p1rlo = temp5
dim p1rhi = temp6
dim p2rlo = aux3
dim p2rhi = aux4
dim p3rlo = aux5
dim p3rhi = aux6

const lthi = >hxl
const rthi = >hxr
const ltlo = <hxl
const rtlo = <hxr

macro get
asm
lda ({1}),y
ora ({2}),y
sta {3}
end
end

macro loadx
asm
ldx #{1}
end
end

macro loady
asm
ldy loff,x
end
end

macro delay
asm
bit $FF
end
end

rem last cycle of sta RESP1 is 39

WSYNC = $00
GRP0 = $00 : GRP1 = $00
REFP0 = $00 : REFP1 = $00
NUSIZ0 = $02 : NUSIZ1 = $02
callmacro delay
VDELP0 = $00 : VDELP1 = $00 : RESP1 = $00 : RESP0 = $00
HMP1 = $B0 : HMP0 = $C0
COLUP0 = $06 : COLUP1 = $06
p3lhi = lthi : p2lhi = lthi

WSYNC = $00
HMOVE = $06
p1rhi = rthi : p0rhi = rthi : p3rhi = rthi : p2rhi = rthi
p0rlo = (scr0 & $0F) + rtlo : p0llo = (scr0 / 16) + ltlo
p3rlo = (scr3 & $0F) + rtlo : p3llo = (scr3 / 16) + ltlo

WSYNC = $00
p1lhi = lthi : p0lhi = lthi
p2rlo = (scr2 & $0F) + rtlo : p2llo = (scr2 / 16) + ltlo
p1rlo = (scr1 & $0F) + rtlo : p1llo = (scr1 / 16) + ltlo

callmacro loadx $05

rem 42..50 cycles to second sta GRP1

WSYNC = $00

hexloop
callmacro loady
callmacro get p0llo p0rlo gr0tmp
WSYNC = $00

asm
dex
bpl .hexskip
bmi .hexexit
end

hexskip
callmacro get p3llo p3rlo GRP1
callmacro get p2llo p2rlo GRP0
callmacro get p1llo p1rlo GRP1
GRP0 = gr0tmp

asm
bne .hexloop
end

hexexit


GRP1 = $00 : GRP0 = $00

return


asm
if (<*) > (<(*+$05))
repeat ($100-<*)
.byte 0
repend
endif
end

rem there's a table of left digits and a
rem table of right digits
rem there's a line in each table corresponding
rem to the each display line numbered 4..0
rem loff is the table offsets for each line

data loff
$00, $40, $30, $20, $10, $00
end

asm
if (<*) > (<(*+$50))
repeat ($100-<*)
.byte 0
repend
endif
end

data hxr
$07, $02, $06, $07, $01, $07, $03, $07, $07, $07, $02, $06, $03, $06, $07, $07
$05, $06, $01, $01, $03, $04, $04, $01, $05, $05, $05, $05, $04, $05, $04, $04
$05, $02, $02, $07, $05, $06, $07, $02, $07, $07, $07, $06, $04, $05, $06, $06
$05, $02, $04, $01, $07, $01, $05, $04, $05, $01, $05, $05, $04, $05, $04, $04
$07, $07, $07, $07, $01, $06, $07, $04, $07, $06, $05, $06, $03, $06, $07, $04
end

asm
if (<*) > (<(*+$50))
repeat ($100-<*)
.byte 0
repend
endif
end

data hxl
$70, $20, $60, $70, $10, $70, $30, $70, $70, $70, $20, $60, $30, $60, $70, $70
$50, $60, $10, $10, $30, $40, $40, $10, $50, $50, $50, $50, $40, $50, $40, $40
$50, $20, $20, $70, $50, $60, $70, $20, $70, $70, $70, $60, $40, $50, $60, $60
$50, $20, $40, $10, $70, $10, $50, $40, $50, $10, $50, $50, $40, $50, $40, $40
$70, $70, $70, $70, $10, $60, $70, $40, $70, $60, $50, $60, $30, $60, $70, $40
end



pfcolors_wtable.bas

pfcolors_wtable.bin

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...