Jump to content
IGNORED

Playfield Variables vs Playfield (and data table)


KevKelley

Recommended Posts

I was trying something out and didn't quite get the results I was thinking would happen so I wanted to get a better understanding as to why.

 

My program's space is limited.  I am trying to finish things up but I have the following space remaining in each of the banks:

 

      1 bytes of ROM space left in bank 1
      41 bytes of ROM space left in bank 2
      6 bytes of ROM space left in bank 3
      6 bytes of ROM space left in bank 4

 

I had thought that instead of using the drawing the entire playfield like this:

 playfield:
 X....X....X....X....X....XXX...X
 X....X....X....X....X....XXX...X
 ................................
 ................................
 .........XX.XXX.XXX.XX..XXX.XXX.
 ..XXXXXXX...X...X.X.X.X..X..X...
 .XX.X.X.X...X...XXX.XX...X...XX.
 .X.X.X.XX...XXX.X.X.X.X..X..XXX.
 ..XXXXXX........................
 ...XXXX..XXXXXXXXXXXXXXXXXXXXXX.
 ..XX..XX........................
end

I could only use certain playfield variables and rewrite a couple of lines and save some space by doing this:

 var16=%00000000 :var17=%01110110 :var18=%11101100 :var19=%01110111 
 var20=%00111111 :var21=%00010001 :var22=%10101010 :var23=%00010010 
 var24=%01101010 :var25=%00010001 :var26=%11101100 :var27=%01100010 
 var28=%01010101 :var29=%01110001 :var30=%10101010 :var31=%01110010 
 var32=%00111111 :var33=%00000000 :var34=%00000000 :var35=%00000000 
 var36=%00011110 :var37=%11111110 :var38=%11111111 :var39=%01111111 
 var40=%00110011 :var41=%00000000 :var42=%00000000 :var43=%00000000 

I had used playfield variables in my game when I needed to change just a small portion of the screen like maybe a couple pixels so I thought this could be an easy way to save space but when I tried to compile I got an error message that listed the remaining bytes as such:

 

segment:  3fd4          eqm       vs current org: 3ffd
      1 bytes of ROM space left in bank 1
      41 bytes of ROM space left in bank 2
      -41 bytes of ROM space left in bank 3

 

The code I was changing was in bank 3 but my question is why would drawing 7 lines of the playfield using playfield variable use more space then drawing the entire thing with "x"s and "."s?

 

Also, when I tried instead using a data table instead I saved space but I couldn't figure out how to read the data, and if that would be a better solution? 

Link to comment
Share on other sites

12 minutes ago, Random Terrain said:

Thanks.  I never noticed this before on your page so I just tried it and the results are the same:

 

 Routine 1:  57   (playfield)
 Routine 2:  144  (playfield variables)
 Routine 3:  47    (data table)

 

I had thought that if I just used a couple playfield variables I would have used much less.  The results were surprising. Basically, in my code I had the screens change but I was thinking that since half of the screen stays the same I could save space by just redrawing half the screen so I was wondering about the workings of the code to understand the differences.

  • Like 1
Link to comment
Share on other sites

Also, try something like this to see if it helps (untested):

 

    for temp5 = 0 to 27
        var17[temp5] = my_screen[temp5]
    next

    data my_screen
    %00000000, %01110110, %11101100, %01110111
    %00111111, %00010001, %10101010, %00010010 
    %01101010, %00010001, %11101100, %01100010 
    %01010101, %01110001, %10101010, %01110010 
    %00111111, %00000000, %00000000, %00000000 
    %00011110, %11111110, %11111111, %01111111 
    %00110011, %00000000, %00000000, %00000000
end

 

Edit: Also, don't forget that the bit order is reversed for the odd-numbered variables, assuming you haven't already taken that into account in your data.

Link to comment
Share on other sites

I had thought about setting a temp variable and doing it that way but I don't think I have any left. Thanks for the answer. It is interesting to hear the going on under the hood. I had a similar question last year as I was working on Crossdock but that was when I switch from using pfpixel to the playfield variables so I just assumed the difference would be great. 

 

Thank you for your response but I will definitely play around with this in the future. I was looking for creative ways to try and save space in my program (or future programs).

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...