Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pascalated ZX BASIC Demo #18 - The Lost Comic Book
#1
To run online, click here: RUN ONLINE

Code:
' PROGRAM The Lost Comic Book
' (c) ZarSoft 2022 Pascalated BASIC
' (c) ZarSoft 2023 Pascalated Boriel ZX BASIC
' Written by Ze Oliveira
' Pascalated Sinclair BASIC (c) 1987 by ZarSoft
' Pascalated BASIC Converter (c) 2021 by Zarsoft
' Pascalated Boriel (c) 2023 by ZarSoft
' ZX BASIC Compiler (c) 2008 by Boriel

#include <input.bas>  ' number = VAL INPUT(12)
#include <screen.bas> ' SCREEN$ function
#include <attr.bas>   ' ATTR function

'--- Pascalated Boriel ---
#define PROGRAM   REM
#define BEGIN    REM
'#define CONST     CONST
#define VAR       DIM
#define INTEGER   LONG
#define REAL      FLOAT
#define CHAR      STRING
'#define STRING    STRING
#define BOOLEAN   UBYTE
#define TYPE      AS
'#define WHILE    WHILE
#define REPEAT    DO
#define UNTIL     LOOP UNTIL
#define PROCEDURE  SUB
CONST   TRUE      TYPE BOOLEAN = 1
CONST   FALSE     TYPE BOOLEAN = 0

PROGRAM The Lost Comic Book

' CONSTant declarations
CONST PHOTO = 100
' STRING CONST not accepted
'CONST TYPE STRING e$ = "................................" : REM empty line
'CONST e$ TYPE STRING = "                                " : REM empty line

' VAR - Global variables
VAR STATE TYPE INTEGER ' automaton state
VAR a$(99,CODE "Z") '  automaton
VAR GameOver TYPE BOOLEAN
VAR k$ ' key
VAR Empty$ ' empty line

PROCEDURE TRON (m TYPE STRING)
  PRINT AT 22,0;m;
  PAUSE 0
END PROCEDURE

DATA 5
DATA "You are in the city of Oporto."
DATA "Your mission, if you choose to accept it, is to find..."
DATA "THE LOST COMIC BOOK."
DATA "You must decide: *Accept or *Decline."
DATA ""

DATA 7
DATA "The nearest comic shop is Bye Bye Tintin."
DATA "*Enter this shop or go to the *Next."
DATA ""

DATA 10
DATA "You enter the shop and search for The Lost Comic Book."
DATA "But you find only Tintin comics."
DATA "You have wasted the whole day."
DATA "You must *Give up."
DATA ""

DATA 12
DATA "The next comic shop is The Wing Shop."
DATA "*Enter this shop or go to the *Next."
DATA ""

DATA 20
DATA "You enter the shop and search for The Lost Comic Book."
DATA "But you find only Asterix comics."
DATA "You have wasted the whole day."
DATA "You must *Give up."
DATA ""

DATA 22
DATA "The next shop is in Coimbra."
DATA "You enter the freeway."
DATA "Time is running out."
DATA "You must go *Faster."
DATA ""

DATA 25
DATA "You are in Coimbra."
DATA "The nearest comic shop is Doc Cartoon."
DATA "*Enter this shop or go to the *Next."
DATA ""

DATA 30
DATA "You enter the shop and search for The Lost Comic Book."
DATA "But you find only Marvel comics."
DATA "You have wasted the whole day."
DATA "You must *Give up."
DATA ""

DATA 32
DATA "The next shop is in Lisbon."
DATA "You enter the freeway."
DATA "Time is running out."
DATA "You must go *Faster."
DATA ""

DATA 35
DATA "You are in Lisbon."
DATA "The nearest comic shop is The Thieves Market."
DATA "*Enter this shop or go to the *Next."
DATA ""

DATA 40
DATA "You enter The Thieves Market and search for The Lost Comic Book."
DATA "But you find only The Phantom comics."
DATA "You have wasted the whole day."
DATA "You must *Give up."
DATA ""

DATA 42
DATA "You see Paradise Cafe across the street and remember the good old days..."
DATA "But time is running out - the shops are almost closed."
DATA "*Enter Paradise Cafe or go to the *Next comic shop."
DATA ""

DATA 50
DATA "You enter Paradise Cafe but the place is different than you remembered... there are no girls..."
DATA "Time is running out - the shops are almost closed."
DATA "Take a *Drink or go to the *Next comic shop."
DATA ""

DATA 52
DATA "While you take a drink you notice that the place is filled with young people working on computers..."
DATA "Now you realize that you are in a Cybercafe - the kids are accessing the internet."
DATA "Sudden you have an ideia... and search for comics on the internet."
DATA "You got 2 answers: www.bdportugal.com and www.bazar0.com."
DATA "What link do you choose?"
DATA "*1 - BD Portugal"
DATA "*2 - Bazar0"
DATA ""

DATA 60
DATA "YOU GOT THE LOST COMIC BOOK!"
DATA "That was fast! Long live the internet!"
DATA "You complete the order and *Exit Paradise Cafe..."
DATA ""

DATA 75
DATA "CONGRATULATIONS!"
DATA "YOU ARE THE MAN!"
DATA "See you next time."
DATA ""

DATA 80
DATA "You reach Vile Books but the shop is closed - is out of business..."
DATA "*Move on."
DATA ""

DATA 90
DATA "You run out of time - the shops are closed."
DATA "*Move on."
DATA ""

DATA 95
DATA "You drive away and stop at Vasco da Gama Bridge."
DATA "You think about what are you gonna do."
DATA "*Jump down or *Try again another day..."
DATA ""

DATA 99
DATA " "
DATA "You better go home and get some sleep."
DATA "Try again tomorrow..."
DATA ""

PROCEDURE ReadKey
REPEAT
  PAUSE 0
  LET k$ = INKEY$
UNTIL k$ <> ""
BEEP .2,5+5*RND
IF k$ >= "a" THEN LET k$ = CHR$( CODE k$ + CODE "A" - CODE "a" )
END PROCEDURE

PROCEDURE LoadPhoto
REM ShowWaitScreen
PRINT AT 0,0;
FOR i = 0 TO 2
  PRINT PAPER 1;INK 1;Empty$;
NEXT i
PRINT PAPER 7;INK 0;AT 1,15;"\A\B";
PRINT PAPER 7;INK 0;AT 2,15;"\C\D";
PRINT AT 3,0;
FOR i = 3 TO 15
  PRINT PAPER 1;INK 1;Empty$;
NEXT i
REM LOAD pixels
PAPER 8 : INK 8
PRINT AT 2,0;
LOAD STR$(STATE)+"a" CODE
PRINT PAPER 0;INK 0;AT 16,0;Empty$;
REM LOAD ATTR
PRINT AT 15,0;
LOAD STR$(STATE)+"b" CODE
PAPER 0 : INK 7
REM CLEAR message zone
FOR i = 23 TO 16 STEP -1
  PRINT AT i,0;Empty$;
NEXT i
PRINT AT 15,0;
END PROCEDURE

PROCEDURE WriteLineOld1
POKE 23692,255 : REM disable scroll message
PRINT
FOR n=1 TO LEN m$
  IF m$(n) <> "*"
    PRINT m$(n);
  ELSE
    LET n = n+1
    PRINT PAPER 6;INK 0;m$(n);
  ENDIF
  BEEP .02,10+10*RND
NEXT n
END PROCEDURE

PROCEDURE WriteLine (m$ TYPE STRING)
POKE 23692,24 : REM disable scroll message
PRINT
FOR n=0 TO LEN m$-1
  IF m$(n) <> "*" THEN PRINT m$(n);
  IF m$(n) = "*" THEN LET n = n+1 : PRINT PAPER 6;INK 0;m$(n);
  IF INKEY = "" THEN BEEP .02,10+10*RND
NEXT n
END PROCEDURE

PROCEDURE RestoreMessage
VAR num TYPE INTEGER
VAR line$ TYPE STRING
RESTORE
READ num
WHILE num <> STATE
  REPEAT
    READ line$
  UNTIL line$ = "" 
  READ num
END WHILE
END PROCEDURE

PROCEDURE WriteMessage
'RESTORE VAL( "Message"+STR$(STATE) )
RestoreMessage
READ m$
WHILE m$ <> ""
  WriteLine(m$)
  READ m$
END WHILE
END PROCEDURE

PROCEDURE ProcessKey
LET STATE = CODE a$(STATE,CODE k$)
IF STATE > PHOTO
  LET STATE = STATE - PHOTO
  LoadPhoto
ENDIF
WriteMessage
IF STATE = 75 OR STATE = 99 THEN LET GameOver = TRUE
END PROCEDURE

PROCEDURE DefineChars
REM \A\B
REM \C\D
' "A"
POKE USR "A"+0, BIN 11111111
POKE USR "A"+1, BIN 11000000
POKE USR "A"+2, BIN 11000000
POKE USR "A"+3, BIN 11001010
POKE USR "A"+4, BIN 11100101
POKE USR "A"+5, BIN 11110010
POKE USR "A"+6, BIN 11111001
POKE USR "A"+7, BIN 11111100
' "B"
POKE USR "B"+0, BIN 11111111
POKE USR "B"+1, BIN 00000111
POKE USR "B"+2, BIN 00000111
POKE USR "B"+3, BIN 10100111
POKE USR "B"+4, BIN 01000111
POKE USR "B"+5, BIN 10011111
POKE USR "B"+6, BIN 00111111
POKE USR "B"+7, BIN 01111111
' "C"
POKE USR "C"+0, BIN 11111101
POKE USR "C"+1, BIN 11111000
POKE USR "C"+2, BIN 11110001
POKE USR "C"+3, BIN 11100000
POKE USR "C"+4, BIN 11000001
POKE USR "C"+5, BIN 11000010
POKE USR "C"+6, BIN 11000101
POKE USR "C"+7, BIN 11111111
' "D"
POKE USR "D"+0, BIN 10111111
POKE USR "D"+1, BIN 00011111
POKE USR "D"+2, BIN 10001111
POKE USR "D"+3, BIN 00000111
POKE USR "D"+4, BIN 10000111
POKE USR "D"+5, BIN 01000111
POKE USR "D"+6, BIN 10100111
POKE USR "D"+7, BIN 11111111
END PROCEDURE

PROCEDURE TheEnd
PAUSE 50
WriteLine("9")
PAUSE 50
WriteLine("8")
PAUSE 50
WriteLine("7")
PAUSE 50
WriteLine("6")
PAUSE 50
WriteLine("5")
PAUSE 50
WriteLine("4")
PAUSE 50
WriteLine("3")
PAUSE 50
WriteLine("2")
PAUSE 50
WriteLine("1")
PAUSE 50
WriteLine("0")
PAUSE 50
'NEW
RANDOMIZE USR 0
END PROCEDURE

PROCEDURE InitGame
BORDER 0 : PAPER 0 : INK 7 : CLS
PRINT "THE LOST COMIC BOOK"
PRINT "(c) 2023 Zarsoft"
PRINT "Pascalated Boriel ZX BASIC demo"
POKE 23609,64 : REM keyboard beep
LET GameOver = FALSE
DefineChars
REM automato
'DIM a$(99,CODE "Z")
LET a$(1,CODE "Start") = CHR$(5+PHOTO)
LET a$(5,CODE "Accept") = CHR$(7)
LET a$(5,CODE "Decline") = CHR$(99)
LET a$(7,CODE "Enter") = CHR$(10+PHOTO)
LET a$(7,CODE "Next") = CHR$(12)
LET a$(10,CODE "Give up") = CHR$(99)
LET a$(12,CODE "Enter") = CHR$(20+PHOTO)
LET a$(12,CODE "Next") = CHR$(22+PHOTO)
LET a$(20,CODE "Give up") = CHR$(99)
LET a$(22,CODE "Faster") = CHR$(25+PHOTO)
LET a$(25,CODE "Enter") = CHR$(30+PHOTO)
LET a$(25,CODE "Next") = CHR$(32+PHOTO)
LET a$(30,CODE "Give up") = CHR$(99)
LET a$(32,CODE "Faster") = CHR$(35+PHOTO)
LET a$(35,CODE "Enter") = CHR$(40+PHOTO)
LET a$(35,CODE "Next") = CHR$(42)
LET a$(40,CODE "Give up") = CHR$(99)
LET a$(42,CODE "Enter") = CHR$(50+PHOTO)
LET a$(42,CODE "Next") = CHR$(80+PHOTO)
LET a$(50,CODE "Drink") = CHR$(52)
LET a$(50,CODE "Next") = CHR$(80+PHOTO)
LET a$(52,CODE "1 BD Portugal") = CHR$(60+PHOTO)
LET a$(52,CODE "2 Bazar0") = CHR$(60+PHOTO)
LET a$(60,CODE "Exit") = CHR$(75+PHOTO)
LET a$(80,CODE "Move on") = CHR$(90+PHOTO)
LET a$(90,CODE "Move on") = CHR$(95+PHOTO)
LET a$(95,CODE "Jump") = CHR$(99)
LET a$(95,CODE "Try again") = CHR$(5+PHOTO)
REM Start first screen
LET STATE = 1
LET k$ = "Start"
'CONST TYPE STRING e$ = "................................" : REM empty line
LET Empty$ = "                                " : REM empty line
ProcessKey
END PROCEDURE

PROCEDURE MainRoutine
InitGame
REPEAT
  ReadKey
  'PRINT "---";a$(STATE,CODE k$);"==="
  'PRINT "---";CODE a$(STATE,CODE k$);"===" : PAUSE 0
  IF a$(STATE,CODE k$) > "" THEN ProcessKey
UNTIL GameOver
TheEnd
END PROCEDURE

PROGRAM The Lost Comic Book
PRINT AT 23,0;"Pascalated Boriel ZX BASIC demo";
PAUSE 1*50
MainRoutine
END PROGRAM
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)