dmsc / fastbasic

FastBasic - Fast BASIC interpreter for the Atari 8-bit computers
GNU General Public License v2.0
139 stars 20 forks source link

Printing from String Arrays #34

Closed ghost closed 4 years ago

ghost commented 4 years ago

I am printing from different string arrays on a single screen. It is for different playing options for a game I am porting into Fast Basic. After I tried to get 5 or more different options, the strings started to get scrambled. Look like they come from a different memory location or the program crashes. I want to do a similar set up like I've done with cartridge games using select and option or joystick to change parameters before starting a game. I am using PRINT "(label)"; OptionXX$(index). I had to drop what I was doing to head to work. Using two different print statements to see if that works.

dmsc commented 4 years ago

Hi!

I am printing from different string arrays on a single screen. It is for different playing options for a game I am porting into Fast Basic. After I tried to get 5 or more different options, the strings started to get scrambled. Look like they come from a different memory location or the program crashes. I want to do a similar set up like I've done with cartridge games using select and option or joystick to change parameters before starting a game. I am using PRINT "(label)"; OptionXX$(index). I had to drop what I was doing to head to work. Using two different print statements to see if that works.

Can you send me (privately if you want)) the failing program? This will allow me to investigate where the memory corruption occurs.

ghost commented 4 years ago

I switched it all over to printing directly from print statements. Got it to work. I can switch some of it back. I also need to look it if Fast Basic supports importing labels from something assembled with CA65.

ghost commented 4 years ago

`'REM PROJECT: BLACK JACK ATARI FAST BASIC. PORTED FROM DARK BASIC VERSION. 'REM CREATED: FRIDAY, AUGUST 10, 2012 'REM MAIN SOURCE FILE

'REM Conversion in Progress DATA BLACKJACKVALUE() BYTE = 11,2,3,4,5,6,7,8,9,10,10,10,10,11 DATA POKERVALUE() BYTE = 15,2,3,4,5,6,7,8,9,10,12,13,14,11

DIM OLDORDER(512) WORD

DBL_DOWN_SET = 0 DBL_DOWN_3UP = 0 DECKSIZE = 52 NUMBER_OF_DECKS = 4

DIM BONUS_777_OPTION_SHOW$(1)
BONUS_777_OPTION_SHOW$(0) = "NO BONUS 777 " BONUS_777_OPTION_SHOW$(1) = "BONUS 777 PAYS 3:1, SUIT 4:1 "

DIM BONUS_678_OPTION_SHOW$(1)
BONUS_678_OPTION_SHOW$(0) = "NO BONUS 678 " BONUS_678_OPTION_SHOW$(1) = "BONUS 678 PAYS 3:1, SUIT 4:1 " BONUS777 = 0 BONUS678 = 0

DEALERTIEWINS = 1

DEALERSOFT17HIT = 0

'DIM UNBUSTED_OPTION_SHOW$(1) CARDCHARLIEWINSET = 6

SPLITSET = 0

'BLACKJACK_BONUS_OPTION_SHOW$(3) = " " SUIT21BONUS = 0 COLOR21BONUS = 0

'DIM NUMBER_OF_PLAYERS_OPTION_SHOW$(3) 'NUMBER_OF_PLAYERS_OPTION_SHOW$(0) = "ONE PLAYER "
'NUMBER_OF_PLAYERS_OPTION_SHOW$(1) = "TWO PLAYER " 'NUMBER_OF_PLAYERS_OPTION_SHOW$(2) = "THREE PLAYER " 'NUMBER_OF_PLAYERS_OPTION_SHOW$(3) = "FOUR PLAYER "

MAXPLAYERS = 4 TRUE = 1 FALSE = 0 LASTPLAYER = 0 DIM CARDIMAGE$(56) CARDBACKIMAGE$ = " " CARDIMAGE$(0) = " " CARDIMAGE$(1) = " " CARDIMAGE$(2) = " " DIM BJCARDVALUE(56 10) BYTE DIM PKCARDVALUE(56 10) BYTE DIM CARDSUITVALUE(56 10) BYTE DIM CARDORDER(56 10) BYTE DIM CARDIMG(60) WORD DIM MODE_RES_X(64) BYTE DIM MODE_RES_Y(64) BYTE DIM MODE_BITDEPTH(64) BYTE DISPPLAYERSPACING = 0 DISPPLAYERLEFT = 0 DISPPLAYERTOP = 0 DISPPLAYERVERTICAL = 0 SELECTED_BITDEPTH = 0 SELECTED_RES_X = 0 SELECTED_RES_Y = 0 DEALERHIDDEN = 0 CARDNO = 0 RESHUFFLENO = 0 NEWCARDVALUE = 0 ROUNDSPLAYED = 0 PLAYERNO = 0 GONEXTPLAYER = 0 ALLOWSPLIT = 0 EXITGAME = 0 NUMBEROFDECKS = 4 DIM PLAYERNNAME$(4) DIM PLAYERNDRAWN(4) BYTE DIM PLAYERNTOTAL(16) BYTE DIM PLAYERNCASH(4) WORD DIM PLAYERNBETENTERY(4) DIM PLAYERNBET(4) DIM PLAYERNSPLIT(4) BYTE DIM PLAYERNACES(4) BYTE DIM PLAYERBJCARDVAL(80) BYTE DIM PLAYERPKCARDVAL(80) BYTE DIM PLAYERSUCARDVAL(80) BYTE DIM PLAYERNSPLITCARD(80) BYTE DIM PLAYERNDOUBLEUSED(4) DIM PLAYERNMESSAGE$(4) DIM HANDREWARD(3) WORD KEYPRESSED$="" ERRORMESSAGE$ = "" LASTKEYPRESSED = 0 DEALERTIEWINS = 0 DEALERSOFT17HIT = 0 ' IF DEALER HAS ONE ACE DEALERNOHIDDEN = 0 CARDCHARLIEWINSET = 6 ALLOWSURRENDER = 0 ' PLAYER GETS BACK HALF BET SUIT21BONUS = 0 COLOR21BONUS = 0 SUITEDAJBONUS = 0 ' ACE + JACK PAY IN SAME SUIT 2:1 JOKERBETRETURN = 0 JOKERSPECIALACE = 0 JOKERSPRESANT = 0 DIM PLAYERNWINS(4) TOTALCARDS = 0 DECKSIZE = 0 SUITSIZE = 0 SS = 0
END_PROGRAM = 0 A=0 B=0 C=0 D=0 E=0 F$="" G=0 H=0 I=0 J=0 K=0 L=0 M=0 N=0 O=0 P=0 Q=0 R=0 S=0 T=0 U=0 V=0 W=0 X=0 Y=0 Z=0 END_PROGRAM = FALSE

EXEC INIT_DEFAULTS
EXEC TITLE_SCREEN

DO
LOOP

'code not used yet removed'

PROC INIT_DEFAULTS LASTPLAYER = 1 DECKSIZE = 52
NUMBER_OF_DECKS = 4 DBL_DOWN_SET = 0 SPLITSET = 0 BONUS777 = 1 BONUS678 = 0 DEALERTIEWINS = 0 DEALERSOFT17HIT = 0 CARDCHARLIEWINSET = 6 SUIT21BONUS = 0
COLOR21BONUS = 0
DBL_DOWN_3UP = 0
ALLOWSURRENDER = 0
ENDPROC

PROC TITLE_SCREEN
A = 0 B = 0 C = 0 I = 0 J = 0 K = 0
L = 0
N = 0
MOUSECLICK = 0 BUTTONUP = 0 SELECTED_MODE = 0 MX = 0 MY = 0 A = 1 N = 1 B = 0

' REPEAT RESET_TITLE = 0 GRAPHICS 0 CLS POKE 82,0 POKE 710,0:POKE 709,12:POKE 712,66 POSITION 0,0 PRINT " Atari Casino Black Jack " POSITION 0,2
PRINT " A Game By Peter J. Meyer"

  POSITION 0,5
  PRINT "   Deck Size:"
  POSITION 13,5
  IF DECKSIZE = 52
    PRINT "48 CARD DECKS(Spanish 21)"
  ELIF DECKSIZE = 48
    PRINT "52 CARD DECKS            "
  ELIF DECKSIZE = 56
    PRINT "56 CARD DECKS            "
  ENDIF

  POSITION 0,7
  PRINT "Number Decks:"
  POSITION 13,7
  IF NUMBER_OF_DECKS = 4
    PRINT "FOUR DECKS  "
  ELIF NUMBER_OF_DECKS = 6
    PRINT "SIX DECKS   "
  ELIF NUMBER_OF_DECKS = 8
    PRINT "EIGHT DECKS "
  ENDIF

  POSITION 0,9
  PRINT " Dealer Hits:"     
  POSITION 13,9
  IF DEALERSOFT17HIT = 0
    PRINT "HOLDS ON 17 OR MORE      "
  ELSE
    PRINT "DEALER HITS SOFT 17      "
  ENDIF
 POSITION 0,11     
 PRINT "  Dealer Tie:"
 POSITION 13,11
 IF DEALERTIEWINS = 0
    PRINT "BET RETURNED. PUSH.      "
 ELSE
    PRINT "LOOSE BET, GOES TO DEALER"
 ENDIF

 POSITION 0,13
 PRINT "Unbust Limit:"
 POSITION 13,13
 IF CARDCHARLIEWINSET = 6 
   PRINT "SIX CARD CHARLIE WINS  "
 ELSE  
   PRINT "FIVE CARD CHARLIE WINS "
 ENDIF

 POSITION 0,15
 PRINT "   Surrender:"
 POSITION 13,15
 IF ALLOWSURRENDER = 0
    PRINT "NO PLAYER SURRENDER      "
 ELSE
    PRINT "ALLOWED HALF BET RETURNED"
 ENDIF  

 POSITION 0,17
 PRINT "   777 Bonus:"
 POSITION 13,17
 IF BONUS777 < 2 
    PRINT BONUS_777_OPTION_SHOW$(BONUS777)
 ENDIF

' POSITION 0,19 ' PRINT " 678 Bonus:" ' POSITION 13,19
' IF BONUS678<2 ' PRINT BONUS_678_OPTION_SHOW$(BONUS678) ' ENDIF

' POSITION 0,21 ' PRINT " Players:" ' POSITION 13,21 ' I = LASTPLAYER ' IF I < 4 ' PRINT NUMBER_OF_PLAYERS_OPTION_SHOW$(I) ' ENDIF

' POSITION 0,17 ' PRINT " Split Rule:" ' POSITION 13,17 ' IF SPLITSET = 0 ' PRINT "SPLIT ANY PAIR 10=(J,Q,K)" ' ELIF SPLITSET = 1 ' PRINT "SPLIT EXACT PAIR " ' ELSE
' PRINT "NO SPLIT ACES " ' ENDIF '
' POSITION 0,19 ' PRINT " Double Down:" ' POSITION 13,19
' IF DBL_DOWN_SET = 0 ' PRINT "ANY TOTAL ALLOWED " ' ELIF DBL_DOWN_SET = 1 ' PRINT "10 OR 11 ONLY " ' ELIF DBL_DOWN_SET = 2 ' PRINT "9, 10, OR 11 ONLY " ' ELSE
' PRINT "UPTO 3 CARDS " ' ENDIF ' ' POSITION 0,21 ' PRINT " Black Jack:" ' POSITION 13,21 ' ' IF SUIT21BONUS = 0 ' PRINT "NO BLACKJACK BONUS ALL 3:2 " ' ELIF SUIT21BONUS = 1 ' PRINT "SUIT BLACKJACK PAYS 2:1 " ' ELIF SUIT21BONUS = 2 ' PRINT "SAME COLOR BLACKJACK PAYS 2:1 " ' ENDIF

'' UNTIL SELECTING=2 OR SELECTING=3

ENDPROC

`

dmsc commented 4 years ago

Hi!

I switched it all over to printing directly from print statements. Got it to work. I can switch some of it back. I also need to look it if Fast Basic supports importing labels from something assembled with CA65.

Yes, you need to use @LABEL for absolute labels and @@LABEL for ZP labels, for example:

    X = USR(@MY_CODE, 123, 456)
    ? PEEK(@@CH)

Have Fun!

ghost commented 4 years ago

Yeah, I am trying to use a custom CFG file with an extra segment for Machine Language and Binary Data like fonts and sprites. It is part of the .xex, but does not create a separate load segment so it loads to the desired program memory location.

dmsc commented 4 years ago

Hi!

`'REM PROJECT: BLACK JACK ATARI FAST BASIC. PORTED FROM DARK BASIC VERSION.

Tried this code, did not see any problem, sorry.

Do you have any failing version?

ghost commented 4 years ago

It may be happening because I had to directory set up pointing to an older Version of Fast Basic. Got it to compile in 4.3, and it works. Now trying to compile with the machine language part. This also includes a font, but it does not load to the desired memory location aligned of every 1K. (1024, 2048, 3072....)

dmsc commented 4 years ago

Hi!

It may be happening because I had to directory set up pointing to an older Version of Fast Basic. Got it to compile in 4.3, and it works. Now trying to compile with the machine language part. This also includes a font, but it does not load to the desired memory location aligned of every 1K. (1024, 2048, 3072....)

In the last FastBasic version (4.4 beta, download over here https://atariage.com/forums/topic/308797-fastbasic-44-beta/ ) there is a section called "ALIGNDATA" in the config file, so the procedure to include data that needs alignment is:

Then, simply compile the FastBasic code with the ASM file.

Have Fun!

dmsc commented 4 years ago

Closing, seems resolved after last comment.