//
// THE PLASMA SANDBOX CAN'T LOAD
// MODULES LIKE THE FULL VERSION, BUT
// IT HAS SOME BUILT-IN FUNCTIONS THAT
// ALLOW EXTENSIVE ACCESS TO THE APPLE'S
// HARDWARE AND SOFTWARE ENVIRONMENT.
// OTHERS ARE JUST CONVENIENT OR ADD
// PERFORMANCE WHERE PLASMA MAY BE TOO
// SLOW
//

CONST TEXTSCREEN = $0400
CONST SCREENSIZE = 1024

BYTE[SCREENSIZE] SAVETXT
BYTE I
WORD NAME

//
// BUILT-IN FUNTIONS:
//
// SYSCALL(CMD,PARAMS)            : CALL PRODOS
// CALL(ADDR,AREG,XREG,YREG,PSP)  : CALL 6502 ROUTINE WITH REG VALUES
// MEMSET(DSTADDR, VALUE, SIZE)   : FILL DSTADDR TO DSTADDR + SIZE WITH VALUE
// MEMCPY(DSTADDR, SRCADDR, SIZE) : COPY SRCADDR TO DSTADDR, SIZE BYTES
// PUTC(CHAR)  : PRINT CHAR
// GETC()      : READ CHAR FROM KEYBOARD
// PUTI(NUM)   : PRINT INTEGER NUMBER
// PUTS(ADDR)  : PRINT STRING AT ADDR
// GETS(CHAR)  : READ STRING FROM KEYBOARD, PROMPTING WITH CHAR
// HOME()      : CLEAR SCREEN AND HOME CURSOR
// GOTOXY(X,Y) : SET CURSOR TO X,Y
//

//
// SAVE THE TEXT SCREEN IN A BIG (1024) ARRAY
//
MEMCPY(@SAVETXT, TEXTSCREEN, SCREENSIZE) // SAVE TEXT SCREEN

//
// CLEAR SCREEN, HOME CURSOR. FOR
// FUNCTIONS WITHOUT PARAMETERS, THE
// "()" ARE OPTIONAL, BUT HELP CLARIFY
// THE FUNCTION CALL IS NOT A VARIABLE
// REFERENCE: HOME VS HOME()
//
HOME()

FOR I = 0 TO 23
  //
  // MOVE CURSOR TO POSITION X, Y
  //
  GOTOXY(I, I)
  //
  // OUTPUT A CHARACTER AND A SPACE
  //
  PUTC('A' + I)
  PUTC(' ')
  //
  // OUTPUT AN INTEGER
  //
  PUTI(I)
NEXT

//
// NOTICE THE '@' IN SOME OF THE FUNCTION
// ARGUMENTS? DID YOU NOTICE THE '^' IN
// THE PREVIOUS EXAMPLE? ALL WILL BE
// EXPLAINED IN EX.4.PLA!
//

GOTOXY(10, 5)
PUTS("WHAT IS YOUR NAME")
NAME = GETS($BF) // GETS NEEDS PROMPT CHAR: '?' + 128
GOTOXY(12, 7)
PUTS("NICE TO MEET YOU, ")
PUTS(NAME)
GOTOXY(16, 10)
PUTS("PRESS ANY KEY TO EXIT.")
GETC()
GOTOXY(0, 5)
MEMCPY(TEXTSCREEN, @SAVETXT, SCREENSIZE)
DONE
