Jump to content
IGNORED

7800basic Tips, tricks and examples


mksmith

Recommended Posts

2 hours ago, Lillapojkenpåön said:

Thanks, I've tried everything for five hours.. I'm just gonna give up on this for about a year just like I did last time I tried ?

It can often be hard to help out with problems like these from descriptions and snippets as the problem itself can potentially be a different part of the code.  If you want to zip up what you have and msg it to me I can see if I can figure out where it's going wrong.

  • Thanks 1
Link to comment
Share on other sites

The score trick "works", but it doesn't.

 

It is plotting in background characters. I have tried setting the characterset and such, but no luck.

 

Any idea what to do in this case?

 

I figure you or @RevEng might find that I am missing a simple step.

 

Thanks,

Darryl

 

Edited by darryl1970
  • Like 1
Link to comment
Share on other sites

Stick the score characters first in the graphics block, before the background tiles. The trick assumes that character index 0 is the character "0", index 1 is the character "1", ...

 

Alternatively you could add an offset to each updated character, when you update the values. Something like...

 

UpdateScore
 const scoreoffset = < scoredigits : rem substitute your score graphic name for "scoredigits" here
 rem replace chars with score
 scoreText5 = (scoreVar2&$0F) + scoreoffset
 scoreText4 = (scoreVar2/16) + scoreoffset
 scoreText3 = (scoreVar1&$0F) + scoreoffset
 scoreText2 = (scoreVar1/16) + scoreoffset
 scoreText1 = (scoreVar0&$0F) + scoreoffset
 scoreText0 = (scoreVar0/16) + scoreoffset
 return

 

  • Like 2
Link to comment
Share on other sites

8 minutes ago, RevEng said:

Stick the score characters first in the graphics block, before the background tiles. The trick assumes that character index 0 is the character "0", index 1 is the character "1", ...

 

Alternatively you could add an offset to each updated character, when you update the values. Something like...

 


UpdateScore
 const scoreoffset = < scoredigits : rem substitute your score graphic name for "scoredigits" here
 rem replace chars with score
 scoreText5 = (scoreVar2&$0F) + scoreoffset
 scoreText4 = (scoreVar2/16) + scoreoffset
 scoreText3 = (scoreVar1&$0F) + scoreoffset
 scoreText2 = (scoreVar1/16) + scoreoffset
 scoreText1 = (scoreVar0&$0F) + scoreoffset
 scoreText0 = (scoreVar0/16) + scoreoffset
 return

 

Is there a way that I can swap them without having to redraw my entire map?

I tried manually changing the order in Notepad++.  image.thumb.png.2516ea002228ddb990c9afd0a5dfa3c1.png

 

No luck with that.

 

There HAS to be an easier way than redrawing the map? No?

 

Darryl

  • Like 1
Link to comment
Share on other sites

The mapfile references the names of the tile graphics it was created with, not the literal character indexes, so you should be able to move the incgraphic for the background tiles around in your 7800basic source without messing things up. (of course, they all still need to be in the same graphics block - ie. in the same character set)

  • Like 1
Link to comment
Share on other sites

1 hour ago, RevEng said:

The mapfile references the names of the tile graphics it was created with, not the literal character indexes, so you should be able to move the incgraphic for the background tiles around in your 7800basic source without messing things up. (of course, they all still need to be in the same graphics block - ie. in the same character set)

I get it now!!  You mean the order of my incgraphics, not the order they appear in my tmx file!!! It worked!

  • Like 4
Link to comment
Share on other sites

  • 4 weeks later...

Large Data Table > 256 Bytes

One of the things a have been struggling with at times is keeping data tables within the default 256 byte size limit.  This is two-fold issue - the table size and calculating an offset. According to the documentation on accessing regular data, the size is limited to 256 bytes and if you wanted to create larger it is suggested to use sequential tables - each has their pros and cons.

 

So what if I told you there is a way to access tables larger than this quickly and easily??

 

Most of us probably use tables for either map data or some sort of grid style layout or lookup. During Millie and Molly development I discovered I could use the peekchar function to replace calculating an offset to my RAM based table containing the background layout (as objects move the background needed to be restored).  This worked great as I could replace a convoluted offset calculation using co-ordinates.  I then expanded this and used the pokechar function to update this and other tables in RAM as needed. 

 

Example

 rem vars
 dim offsetX = var0
 dim offsetY = var1
 dim objectIndex = var2
 
 rem lookup loop
 for offsetY = 0 to 25
  for offsetX = 0 to 12
    rem get object
    objectIndex = peekchar(levelPlayfield,offsetX,offsetY,13,26)
    rem TODO: add you code here...
  next
 next

 data levelPlayfield
 1, 2, 2,12,13, 2, 2, 2,12,13, 2, 2, 3
 4,14,14,14,14,14,14,14,14,14,14,14, 8 
 5,15,15,15,15,15,15,15,15,15,15,15, 9
 6,14,14,14,14,14,14,14,14,14,14,14,10
 6,15,15,15,15,15,15,15,15,15,15,15,10
 7,14,14,14,14,14,14,14,14,14,14,14,11
 4,15,15,15,15,15,15,15,15,15,15,15, 8
 5,14,14,14,14,14,14,14,14,14,14,14, 9
 6,15,15,15,15,15,15,15,15,15,15,15,10
 6,14,14,14,14,14,14,14,14,14,14,14,10
 7,15,15,15,15,15,15,15,15,15,15,15,11
 4,14,14,14,14,14,14,14,14,14,14,14, 8
 5,15,15,15,15,15,15,15,15,15,15,15, 9
 6,14,14,14,14,14,14,14,14,14,14,14,10
 6,15,15,15,15,15,15,15,15,15,15,15,10
 7,14,14,14,14,14,14,14,14,14,14,14,11
 4,15,15,15,15,15,15,15,15,15,15,15, 8
 5,14,14,14,14,14,14,14,14,14,14,14, 9
 6,15,15,15,15,15,15,15,15,15,15,15,10
 6,14,14,14,14,14,14,14,14,14,14,14,10
 7,15,15,15,15,15,15,15,15,15,15,15,11
 4,14,14,14,14,14,14,14,14,14,14,14, 8
 5,15,15,15,15,15,15,15,15,15,15,15, 9
 6,14,14,14,14,14,14,14,14,14,14,14,10
 6,15,15,15,15,15,15,15,15,15,15,15,10
 7,14,14,14,14,14,14,14,14,14,14,14,11
end

Full example

The following attachment contains a full working example for the above: 

LargeDataTable.zip

 

Dev Notes

  • Talking to @RevEng about it the only real limitation potentially is your X,Y needs to stay within the 256x256 limit (this is theory only!)

 

PEEKCHAR command

 value = peekchar(mapdata, x, y, width, height)

 mapdata - RAM or ROM location of the data to get
 x - x screen column co-ordinate
 y - y screen row co-ordinate
 width - total width of the map
 height - total height of the map

POKECHAR command

 pokechar mapdata x y width height value

 mapdata - RAM or ROM location of the data to set
 x - x screen column co-ordinate
 y - y screen row co-ordinate
 width - total width of the map
 height - total height of the map
 value - value to be stored

 

  • Like 6
Link to comment
Share on other sites

  • 1 month later...

Singlewide Text in Doublewide Mode

@Muddyfunster recently posted about how you might display singlewide text when doublewide mode is activated. Thanks to @Karl G and @RevEng there is now an answer to how this can be achieved. Make sure to read the original post to fully understand the scenarios where this feature applies.

 

The main decision with using doublewide mode it is an all-in feature. For most games or applications this work great and allows 7800basic to be fully optimised and produce small and very fast assembly.  Occasionally there may be a requirement to use both doublewide for the game proper and singlewide for status and instruction screens.

 

Example

The following example activates doublewide mode for compile purposes and then de-activates it as required before the display is built.  The other requirement is appending plotchars with singlewide to allow 7800basic to identify this requirement.

 set doublewide on
 displaymode 160A

 rem disable double-wide mode
 gosub DisableDoubleWideMode

 rem main
MainLoop
 clearscreen

 rem flag as singlewide to draw correctly
 plotchars 'hello from 7800basic!' 0 0 0 singlewide 
 
 drawscreen
 goto MainLoop

 rem --------------------------------------------------------------------------
 rem DOUBLEWIDE MODE
 rem --------------------------------------------------------------------------
EnableDoubleWideMode
 sCTRL{4} = 1 : CTRL = sCTRL
 return

DisableDoubleWideMode
 sCTRL{4} = 0 : CTRL = sCTRL
 return

Full example

The following attachment contains full working examples for the above:

DoubleWide.zip

 

Using Doublewide and Singlewide fonts together

There may be times where you need to utilise both Doublewide and Singlewide fonts within the same game or application.  Using the same basic principles outlined this can be achieved if required.  The key requirement is a consistent alphachars initialisation with both fonts using the exact same characters and each font existing in it's own gfx block. You also cannot mix modes.

 

Full example

The following attachment contains full working example:

Multifont.zip

 

Dev Notes

  • You cannot mix and display both doublewide and singlewide characters at the same time
  • This is an advanced technique and is not always guaranteed to work with all features in 7800basic due to the compiler optimising the assembly as it's builds your game
  • You should always set doublewide on to ensure all language features requiring this mode continue to work as expected and deactivate/reactivate the mode as you display your status screens 
  • Always use an consistent alphachars initialisation and both fonts using the exact same characters
  • If using multiple fonts you are required to use different gfx blocks

 

PLOTCHARS command

 plotchars textdata palette_# x y [chars|extrawide|singlewide]

 textdata - RAM, ROM or literal string 'message' to plot onto the screen 
 palette_# - index of palette (0-7)
 x - x screen co-ordinate
 y - y line (zone) co-ordinate
 chars (optional) - number of characters to display 
 extrawide (optional) - display chars twice the width of the character size
 singlewide (optional)*

 

  • Like 8
Link to comment
Share on other sites

3 hours ago, SlidellMan said:

Matt, I wonder if you have anything planned for item tables, individual levels, or even boss battles if one is inclined?

@SlidellMan Certainly happy to pop up anything like that once I setup a decent example.  Will keep that sort of thing in mind for future tips!

  • Thanks 1
Link to comment
Share on other sites

Hi everyone,

 

I've updated the TallSprite example for the recent changes in 7800basic (v0.16 onwards) and added additional information how to cater for using QuickScore in doublewide character mode. 

  • Like 6
Link to comment
Share on other sites

  • 1 month later...

Hi Everyone,

 

I've updated the Singlewide Text in Doublewide Mode item with an additional example which shows how to use both doublewide and singlewide fonts in the same game or application.

  • Like 3
  • Thanks 2
Link to comment
Share on other sites

11 minutes ago, SlidellMan said:

I wanted to ask you if 7800Basic's alphachars can support non-standard letters such as æ, ð, and þ? (Ditto for accented vowels and consonants.) By the way, you're free to use my shooter demo as a project template if you so desire.

Hey SlidellMan,

According to RT's 7800basic guide:

Quote

7800basic doesn't “know” the letters A, B, C. Instead, your alphachars statement tells 7800basic that any alphadata commands that follow should represent the space, A, B, C, and D, as the 0th, 1st, 2nd, and 3rd characters in the image file.

https://www.randomterrain.com/7800basic.html#alphachars_and_alphadata

 

So it may be possible to utilise them but one potential issue is that the compiler may not like them? (worth a try I guess!).  Saying that there is nothing stopping you from representing these characters in your on-screen font using standard ASCII characters.

 

I was going to send you this new example as it represents your situation in your game giving you the ability to use a larger font on the title and the smaller font in-game for the score.  Just remember you cannot mix these on-screen at the same time.

 

  • Like 1
  • Thanks 1
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...