BasiEgaXorz v1.37 Documentation
Sega Genesis Tiny BASIC Compiler
Author: DevSter (Joseph Norman)
http://devster.monkeeh.com

"Programming for the Sega Genesis is now as easy as jacking your grandmother's stash of porn"
- Bobo Gates

For a possible newer version of this document, visit http://devster.monkeeh.com/sega/basiegaxorz/
Index
Introduction
Basiegaxorz is a BASIC compiler for the Sega Genesis. This compiler is aimed for speed, so there are many (all) things that cannot be dynamic, everything is static. Line labels are supported too - yay.

Document Syntax
Expression - A listing of values. Ex: 1+2+3=5, a=4, q<>4+5, etc.
Statement, Command, Instruction - They are these: Commands. All commands have to have a space in front of them, unless they are followed by a label.
Label - A marking that marks the line. All labels cannot have a space in front of them!
Variable - Integer/String, you name it

If arguments enclosed in < > in this document, then that argument is not optional. Optional arguments are enclosed in [ ].

Commands
Note: All commands have to have a space/tab in front
PRINT
CLS
GOTO
FOR....NEXT
DIM
IF....ELSE....ENDIF
SLEEP
DATA
DATAINT
DATALONG
DATAFILE
READ
READINT
READLONG
RELOAD
RESTORE
WHILE....WEND
END
LOCATE
GOSUB
RETURN
ON <EVENT>
ENABLE
DISABLE
SHLINK
INK
LOADTILES
DRAWTILE
DRAWTILES
PROPSPRITE
MOVESPRITE
FREESPRITE
HIDESPRITE
PALETTE
SCROLL
SHIFTSPRITE
RANDOMIZE
OPTION
POKE
POKEINT
POKELONG
BRIGHTEN
DARKEN
HBLANK
PALETTES
ASM
LIBRARY
CALL
PSG
PSGVOL
HALT
VALT
DALT
TRAPCPU
INPUT
WAITPADUP
BGCOLOR
FREEALLSPRITES
SETTEXTPLANE
SETGFXPLANE
WINDOWPROP
PUTS
SCROLL2
SETSCROLLMODE
SETSCROLLPLANE
CONTINUE WHILE
CONTINUE FOR
EXIT WHILE
EXIT FOR
RegMove.B
RegMove.W
RegMove.L
Gets
Sleep2
TVSet
Fake
VdpRamWrite
MemCopy
FastTileCopy
DrawTilesOvr
DrawTilesInc
Const
Include
Write
WriteInt
WriteLong
WriteP
DIM xxx AT xxx
VidMode
LoadFont
WaitRaster
TileOrg
VIData
VIDataInt
VIDataLong
VIDataFile

Commands in Alphabetical Order
Note: All commands have to have a space/tab in front
ASM
BGCOLOR
BRIGHTEN
CALL
CLS
CONST
CONTINUE WHILE
CONTINUE FOR
DALT
DARKEN
DATA
DATAFILE
DATAINT
DATALONG
DIM
DIM xxx AT xxx
DISABLE
DRAWTILE
DRAWTILES
DRAWTILESINC
DRAWTILESOVR
ENABLE
END
EXIT WHILE
EXIT FOR
FAKE
FASTTILECOPY
FOR....NEXT
FREEALLSPRITES
FREESPRITE
GETS
GLOBAL
GOSUB
GOTO
HALT
HBLANK
HIDESPRITE
IF....ELSE....ENDIF
INCLUDE
INK
INPUT
LIBRARY
LOADFONT
LOCAL
LOCATE
LOADTILES
MEMCOPY
MOVESPRITE
ON <EVENT>
OPTION
PALETTE
PALETTES
POKE
POKEINT
POKELONG
PRINT
PROPSPRITE
PSG
PSGVOL
PUTS
RANDOMIZE
READ
READINT
READLONG
REGMOVE.B
REGMOVE.W
REGMOVE.L
RELOAD
RESTORE
RETURN
SCROLL
SCROLL2
SETGFXPLANE
SETSCROLLMODE
SETSCROLLPLANE
SETTEXTPLANE
SHIFTSPRITE
SHLINK
SLEEP
SLEEP2
TileOrg
TRAPCPU
TVSET
VALT
VDPRAMWRITE
VIDMODE
VIData
VIDataInt
VIDataLong
VIDataFile
WAITPADUP
WaitRaster
WHILE....WEND
WINDOWPROP
WRITE
WRITEINT
WRITELONG
WRITEP

Command_PRINT:
Syntax: Print <Expression 1>,<Expression 2>,......
Description:Prints characters onto the screen. If a comma (,) is encountered, then a tab is placed. If a semi colon is encountered, then leading characters will be directly displayed appended to the last.
Back to the ABC Command Index

Command_CLS:
Syntax: Cls
Description: Clears the frickin screen
Back to the ABC Command Index

Command_GOTO:
Syntax:Goto <Label>
Description: Jumps to <Label>
Back to the ABC Command Index

Command_FOR:
Command_NEXT:

Syntax:
For <Integer Variable> = <Initial Expression> to <Final Expression> [step <Increment>]
....Commands
....Commands
Next

Description: Creates a loop by putting an initial value into <Integer Variable>, and then incrementing it by the step (is step <increment> is not specified, then 1 is used) until it reaches the value in <Final Expression>. Expressions are not calculated during run-time! Expressions are first calculated when the For command if first identified, and the value is then stored into memory. DO NOT use a Goto command to jump outside of the For....Next loop! Only use goto's to jump to a label inside the loop. For....Next counts are not checked, so if you forget a Next statement, you're program's gonna crash and burn.
Back to the ABC Command Index

Command_DIM:
Syntax: Dim <Variable>(Dimmensions) As <Variable Type> [* <String Size>], <Variable>(Dimmensions) As <Variable Type> [* <String Size>], ...
Description: Dimensions a variable. There are three main data types: Integer, Long, and String. Integers are used for real numbers that are 16 bits wide (representing numbers -32768 to 65535). Integers have a % suffix (ommiting the suffix on a variable makes the compiler assume the variable is integer though). Long variables are used for much bigger numbers, and always need to have an & suffix! Strings are used to hold words, or a string of characters, and have to have a $ suffix. The size of strings can be specified by including the number of bytes of the string after STRING with a *.

Newer versions of BasiEgaXorz support multi-dimensional arrays. To specifiy dimensions for your array, enclose the dimensions of your array in between ( and ) after the variable name. For advanced users, there is another way to dimmension variables by specifying the address location of the variable. See DIM xxx AT xxx for more details. Also see the GLABAL and LOCAL commands on how to define variables in programs that contain user-defined subroutines or functions.
Back to the ABC Command Index

Command_DIM_xxx_AT_xxx:
Syntax: Dim <Variable>(Dimmensions) As <Variable Type> [* <String Size>] At <Location>, <Variable>(Dimmensions) As <Variable Type> [* <String Size>] At <Location>, ...
Description: Dimensions a variable, where the programmer specifies the location of the variable in memory. There are three main data types: Integer, Long, and String. Integers are 16 bits wide, long variables are 32-bit wide, and strings are blocks of 8-bit wide characters. The location of the variable can be represented by a constant number, specifying the absolute address of the variable within the 68k memory space (eg: 12345, or &h3039). The location can also be represented by a label in the source. The label will always point to data (eg: data defined by the commands DATA, DATAING, DATALONG, DATAFILE, etc). Label checking must be enabled in options first, prior to using labels. The location can also be specified with the @ character, or the * asterik (both characters perform the same thing!), and using these symbols will point the location of your variable to the current location of the data counter, or to the next DATA statement.

So why is it useful to specify locations of variables? One of the main advantages is to treat data within the ROM (or RAM, if compiling for the SEGA CD unit) like variables, refered to by "Fake Variables" by devster.
Back to the ABC Command Index

Command_IF:
Command_ELSE:
Command_ENDIF

Syntax 1:
If <Expression> Then
....Instructions if true
....Instructions
EndIf

Syntax 2:
If <Expression> Then
....Instructions if true
....Instructions
Else
....Instructions if false
....Instructions
EndIf

Desctiption: Performs a check on the expression. Blah blah, should be self explanitory, if not, check a basic tutorial. False=$00, True=Any other value. ElseIf is not supported.
Back to the ABC Command Index

Command_SLEEP:
Syntax: Sleep <Integer Expression>, [TVBLANK]
Description: Pauses execution for (1/60) seconds, or ~16.67 ms. for every unit of the Expression. For example, using a value of 60 pauses execution for 1 second. If the TVBLANK keyword is present in the second argument, the sleep command ends at the begining of the verticle blank. By default, when TVBLANK is not present, the sleep command will end sleeping time at the begining of the displaying period. The extra extension is great for when you want to load tiles to VRAM right after the sleep command (tiles load faster because the VDP should be idle at this time).
Back to the ABC Command Index

Command_DATA:
Syntax: Data <Constant 1>,<Constant 2>,........
Description: Insets data into the basic program that can be read by command Read. Any data has to be byte-long (see DATAINT for 16-bit data, and DATALONG for 32-bit). Strings can be used in the DATA statement. The latest release of BasiEgaXorz no longer requires the user to zero-terminate any strings, and the newer compiler is backwards compatible with strings that were zero-terminated manually. An example string usage: Data "Hello Data!". If a value greater than 255 is used (exceeding the byte-long data limit), the file will not compile.
Back to the ABC Command Index

Command_DATAFILE:
Syntax: Datafile <Data File>,[BIN]
Description: Inserts data from an external file into the basic program that can be read by command Read. <Data File> has to be a file inside the compiler directory. When keyword BIN is used, the file will be included as a binary file. Example: Datafile Levels.dat,BIN. If BIN is left out, then the file will be included as a text. Proper text file syntax (same as assembler):
dc.b <Byte Constants 1>,<Byte Constants 2>......
dc.w <Word Constants 1>,<Word Constants 2>......
dc.l <Long Constants 1>,<Long Constants 2>......
Back to the ABC Command Index

Command_READ:
Command_READINT:
Command_READLONG:
Syntax:
Read <Variable 1>,<Variable 2>,........
ReadInt <Variable 1>,<Variable 2>,........
ReadLong <Variable 1>,<Variable 2>,........
Description: Reads data from the Data statements. If the Read command is used for the first time, then data will be read at the very first Data statement. After that, data will be read one after the other, increasing the data pointer, until a Reload command resets the pointer. If <Variable> is an integer, then data will be read, and the msb will be set to 0. If <Variable> is a string, then the data will be copied into a string one byte after the other until a NULL (0 - Zero) is reached.
Back to the ABC Command Index

Command_RELOAD:
Command_RESTORE:
Syntax: Reload [Line Number/Label]
Description: Resets the data pointer to the start of label. The label that Reload is directed to has to be directly in front of the data statement. For example: MyData: data "Wassup",0,45. When [Label] is ommited, the data pointer is reset to the very first Data statement.
Back to the ABC Command Index

Command_WHILE:
Command_WEND:

Syntax:
While <Expression>
....Instructions
....Instructions
Wend

Description: Keeps on looping until <Expression> is false.
Back to the ABC Command Index

Command_END:
Syntax: End
Description: Stops execution.
Back to the ABC Command Index

Command_LOCATE:
Syntax: Locate <Row>,<Column>
Description: Repositions the text cursor at <Row> and <Column>. The range for row is 0 to 25, and the range for column is 0 to 37. If <Row> or <Column> is omitted, then the corresponding cursor argument will not be changed. If the cursor is moved out of range, the program will not check for this, and text will end up being displayed out of the screen, unless the screen is scrolled. Permitted:
Locate 1,2 ' Will move cursor to row 1, column 2
Locate 3, ' Will move cursor to row 3, column unchanged
Locate ,5 ' Will move cursor to column 5, row unchanged

Back to the ABC Command Index

Command_GOSUB:
Syntax: Gosub <Label>
Description: Jumps program execution to <Label>. Program execution is returned to the instruction after the Gosub instruction after a Return command is found. Branches may be stretched to inifinite, depending on how much stack space is left.
Back to the ABC Command Index

Command_RETURN:
Syntax: Return
Description: Returns program execution to the instruction after the last Gosub command.
Back to the ABC Command Index

Command_ON_EVENT:
Syntax: On <Event> Gosub <Label>
Description: On the interruption of <Event>, the program will immediately change program execution to the specified <Label>. An event cannot be restarted if the program is executing in an event subroutine. An event subroutine may be ended by a Return command. The cursor location is always saved - if people don't like this, tell me and i'll remove that.
List Of Events:
VBLANK - Verticle Blank Interrupter. Occurs 60 times per second.
HBLANK - Horizontal Blank Interrupter.
EXTINT - External Interrupter (found on controller ports). Read the ENABLE command for a better description of external hardware interrupters.
Back to the ABC Command Index

Command_ENABLE:
Syntax: Enable <Thing>
Description: Enables <Thing>.
Values for <Thing>:
INTERRUPT VBLANK - Turns on the verticle blank interrupt. This command has to be executed in order for VBLANK events to be triggered. It is recommended that this instruction be placed anywhere after an On <Event> command.
INTERRUPT HBLANK - Turns on the horizontal blank interrupt. This command has to be executed in order for HBLANK events to be triggered. It is recommended that this instruction be placed anywhere after an On <Event> command.
INTERRUPT EXTERNAL, <Joypad Number> - Turns on the external interrupter. External interrupters occur on the controller/extension ports. The external interrupter is triggered when a Logic LOW on the TH pin of the controller port is pulsed. When the interrupter occurs, the HV counter is latched (eg: for making an easy light-gun interface). Since the HV counter is being latched, I believe you won't be able to read the HV counter during normal program execution (outside the interupter) like you would for doing rasters. When the counter is latched, that means it will stay a constant value, and will not update itself with the TV trace. To re-enable HV counter real time reading, disable this interupter. <Joypad Number> is a number between 0 and 2 (0=Player 1, 1=Player 2, 2=Extension port found on old Segas).
SCREEN - Turns on all screen displaying.
Back to the ABC Command Index

Command_DISABLE:
Syntax: Disable <Thing>
Description: Disables <Thing>.
Values for <Thing>:
INTERRUPT VBLANK - Turn off the verticle blank interrupt. See On <Event> to make use of this.
INTERRUPT HBLANK - Turns off the horizontal blank interrupt. This command has to be executed in order for HBLANK events to be triggered. It is recommended that this instruction be placed anywhere after an On <Event> command.
INTERRUPT EXTERNAL, <Joypad Number> - Turns off any external interrupters from the controller/extension ports. You still need to specify the Joypad number in order to properly make the joypad function like it use to. The HV counter is no longer being latched after this command, so now you can read the HV counter.
SCREEN - Turns off all screen displaying. Blanking signals are still sent to the TV, and the backdrop color is the only component drawn during the active display period. Note: Verticle and Horizontal interrupters and status signals are disabled when the screen is off, so the command Sleep and other status signal dependent routines will freeze.
WINDOW - Resets the window.
Back to the ABC Command Index

Command_SHLINK:
Syntax: Shlink <Label>
Description: Jumps program execution to <Label>. It is only recommended that this command only be used in an event subroutines to jump immediatly to <Label>. Normally, you cannot use Goto to jump outside of an event subroutine. I thought this command might be useful for things where many instructions are being executed in the main program loop, where there is no room to read the joypad, and therefore needs to use an event to check the joypads, and jump out of the main program loop at a certain condition. Also, this resets the stack space, so if you had subroutines called with Gosub in the main program loop, then these subroutines will be immediatly killed, and you cannot use Return to jump to the instruction right after the relevant Gosub instruction.
Back to the ABC Command Index

Command_INK:
Syntax: Ink <Pattern>
Description: Changes the color of the drawing text to <Pattern>. The range is from 0 to 3. The default colors for <Pattern> on reset are:
0 - White
1 - Cyan/Baby blue
2 - Green
3 - Purple/Magenta
Back to the ABC Command Index

Command_LOADTILES:
Syntax: LoadTiles <Tile Data Label>, <Tiles Count>, <Tile Destination in Video Memory>, [Tile Source Offset from Label]
Description: Loads tiles into video memory. <Tile Data Label> points to the Label that tile data will be loaded from. This has to be a label with a corresponding data/datafile statement. <Tiles Count> is the number of tiles that will be loaded. One unit of <Tile Count> is equal to one 8*8 tile. <Tile Destination in Video Memory> points to the destination tile number that these tiles will be copied to. One unit of <Tile Destination.....> is equal to one 8*8 tile, and the destination starts at 0 and end at 1343. So, the video memory can hold 1344 simultaneous tiles (43008 bytes of VRAM). Tile numbers 0 to 255 is the text font. [Tile Source Offset from Label] is an optional argument, where it starts copying tiles after so and so tiles in the <Tile Data Label>. On unit of <Tile Data Label> is equal to one 8*8 tile. For example, if [Tile Source Offset from Label] is twelve, then tiles will be loaded twelve tiles after the data label. If this argument is ommited, then a value of 0 is used.
Back to the ABC Command Index

Command_DRAWTILE:
Syntax: DrawTile <tile vram offset>, <x>, <y>
Description: Draws one tile on the screen at <x> and <y>. One unit of X or Y is equal to one 8*8 cell. X and Y start at (0,0), and that is the very upper left part of the screen - FYI: Text starts drawing at (1,1). <Tile VRAM Offset> is the tile number that will be drawn. One unit of this is equal to one 8*8 tile.
Back to the ABC Command Index

Command_DRAWTILES:
Syntax: DrawTiles <label>, <tile vram offset>, <x>, <y>, <width>, <height>, [Data Label Offset]
Description: Draws one or more tiles on the screen at <X> and <Y> that is <Width> and <Height> big. One unit of X, Y, Width, or Height is equal to one 8*8 cell. X and Y start at (0,0), and that is the very upper left part of the screen. <Tile VRAM Offset> is the tile number that will be drawn. One unit of this is equal to one 8*8 tile. <Label> is a data label were the drawing map is located. The data has to be in byte format (using Data). The command draws the map in the order from left to right, up to down.
Back to the ABC Command Index

Command_PROPSPRITE:
Syntax: PropSprite <sprite number>, <tile vram offset>, <palette>
Description: Sets the drawing tile, and color palette of a sprite. <sprite number> is the sprite handle recieved from AddSprite(). [tile vram offset] is the tile that is shown by the sprite, in video memory. One unit of [tile vram offset] is one 8*8 cell. [palette] is the palette number to designate the sprite for color generation. [palette] is in the range from 0 to 3.
Back to the ABC Command Index

Command_MOVESPRITE:
Syntax: MoveSprite <sprite number>, <x>, <y>
Description: Changes the locations of a sprite. <sprite number> is the sprite handle recieved from AddSprite(). X and Y are the locations to move the sprite to. One unit of X and Y are equal to one pixel. Sprites are shown on the screen starting at (128,128). eg: MoveSprite MySprite%,200,250 will move the sprite to (200,250), but the sprite will actually appear at (72,122) on the screen. Any value less than 128 is used to hide the sprite.
Back to the ABC Command Index

Command_FREESPRITE:
Syntax: FreeSprite <sprite number>
Description: Destroys the sprite, and frees up that handle to be used for another sprite. <sprite number> is the sprite handle recieved from AddSprite().
Back to the ABC Command Index

Command_HIDESPRITE:
Syntax: HideSprite <sprite number>
Description: Hides the sprite from the active display area. It actually relocates the sprite to (0,0) for actual coordinates, or (-128,-128) for coordinates relative to the actual display. Sprite is not destroyed, unlike the FreeSprite command.
Back to the ABC Command Index

Command_PALETTE:
Syntax: Palette <RGB Code>, <palette number>, <color number>
Description: Changes the color make-up of one palette entry. The Genesis has a total of 4 palettes, and each palette holds 16 colors (each tile is made up of 1 pixel=4 bits). <palette number> is the palette number in the range 0 to 3. <color number> is the color entry inside the palette, in a range from 0 to 15. Color entry #0 for each palette is transparent for sprites. You can use the function RGB() to get the <RGB Code> using the 3 different color components: red, green, blue.
RGB Code Bit Format
MSB ooooBBBoGGGoRRRo LSB
o's = Value of 0
RRR = Red value, 0 to 7
GGG = Green value, 0 to 7
BBB = Blue value, 0 to 7
Back to the ABC Command Index

Command_SCROLL:
Syntax: Scroll <UP/DOWN/LEFT/RIGHT>, [Quantity], [Entry]
Description: Scrolls a background plane. <UP/DOWN/LEFT/RIGHT> is the direction to scroll in. [Quantity] is the displacement to shift the screen corresponding to its direction. [entry] is the scroll entry. If the scroll mode for a direction is HSCROLL_OVERALL or VSCROLL_OVERALL, then [entry] can be ommited. If the scroll mode for a direction is HSCROLL_CELL then [entry] specifies which horizontal cell will be scrolled, where one unit of [entry] equals 8 horizontal lines (in pixels).If the scroll mode for a direction is HSCROLL_LINE then entry specifies which horizontal line will be scrolled, where one unit of [entry] equals one pixel high line. If the scroll mode for a direction is VSCROLL_2CELL then entry specifies which verticle line will be scrolled, where one unit of [entry] equals a width of two cells (two cells equals 16 pixels). The Scroll command does not scroll sprites along with the background plane. Sprite will have to be shifted manually, if desired.
Back to the ABC Command Index

Command_SHIFTSPRITE:
Syntax: ShiftSprite <sprite number>, <dx>, <dy>
Description: Relatively moves the sprite (a shift, or scroll). The command does not set the sprite's X and Y coordinates, compared to the command MoveSprite. <sprite number> is the sprite handle recieved from AddSprite(). <dx> and <dy> are the change in X and Y to move the sprite. Example directions: dx=-1 and dy=0 will move the sprite left by one pixel, dx=2 and dy=5 will move the sprite right by 2 pixels and down by 5 pixels, dx=-10 and dy=-1 will move the sprite left by 10 pixels and up by 1 pixel.
Back to the ABC Command Index

Command_RANDOMIZE:
Syntax: Randomize [seed]
Description: Changes the seed for the random number generator. Changing the seed is essential for making sure that each number being coming out of the random number generator is unique. Having the same seed throughout the program will yield the same pattern of numbers coming out of the random number generator. Ignoring a value for seed will just substitute the video's HV counter for the seed. A good way to make use of getting pure random numbers is to place a Randomize statement right after a joypad routine has detected a key.
Back to the ABC Command Index

Command_OPTION:
Syntax: Option <setting>, <Value>
Description: Changes compilation options
<Setting> <Value> Description
DEDICATED SEGACD - Tells the compiler to compiler only for the Sega CD
TITLE A Title Sets the title for a Cartidge game
STRING SIZE Size Changes the default string size. The default string size is 128
SEGACD - Overrides settings in the Options dialog, and compiled the program to a Sega Boot CD
SEGACD PROGRAM - Overrides settings in the Options dialog, and compiled the program to a Sega CD Program. Sega CD Programs can be used for programs on a Sega Boot CD. They can also be used on MoD's Transfer Suite.
CARTRIDGE - Overrides settings in the Options dialog, and compiled the program to a ROM cartridge
REORGCODE Address Sets the compiler base address for Sega CD programs
REORGVARS Address Sets the compiler base address to place variables
EXTERNAL SRAM <Start Address>, <Size>, [EVEN/ODD/BOTH] Allocates external SRAM space for external variables. All external variables begin with ext_
FONTFOREENTRY <Palette entry 0-15> Changes the palette entry that text printing commands will use to draw the foreground of text, or font. The default palette entry is entry 1.
FONTBACKENTRY <Palette entry 0-15> Changes the palette entry that text printing commands will use to draw the background of text, or font. The default palette entry for the background is entry 0 / transparent.
EXPLICIT - When OPTION EXPLICIT is defined in the program, all variables will have to be declared. Failure to declare a variable before using it will show an error. This option will overwrite the option set in the options panel.
CASESENSE - Turns off case sensitivity checking of variables and labels.
CASESENSEOFF - Turns off case sensitivity checking of variables and labels. Same exact thing as OPTION CASESENSE.
CASESENSEON - Turns on case sensitivity checking of variables and labels. Variables and labels that have different cases (same spelling, but different capital/lowercase characters) will be recognized different by the compiler.
RUNSCRIPTS xxx Not implemented in public releases of basiegaxorz yet.
TEXTPRIORITY HIGH / LOW Sets the tile priority of text printed using the text printing commands. Use as simply: OPTION TEXTPRIORITY HIGH, or OPTION TEXTPRIORITY LOW. This command makes no difference in distinguishing priorities between tile planes A and B, but sprites that are shown over high priority text will be shown behind the text.
GLOBALVARS - Defines all variables in a program to be global. This option will even overwrite variables defined by the LOCAL command.
TEXTHEIGHT <Number> Sets the maximum height limits for text printing commands to print on the screen. If text goes past the bottem of the screen, a vram DMA routine will shift all characters up by 1. The default value used in BasiEgaXorz is 26.
TEXTWIDTH <Number> Sets the maximum width limits for text printing commands to print on the screen. If text goes past the right of the screen, text will continue to be printed, starting on the next line, at the first column. The default width value used in BasiEgaXorz is 38.
TEXTSTART <Row>, <Column> Sets where the text displaying routines will start drawing text. The default row is 1 and the defualt column is 1.
NOLOADFONT - Forces the startup code to not load the system font at startup.
Back to the ABC Command Index

Command_POKE:
Command_POKEINT:
Command_POKELONG:

Syntax:
Poke <CPU Address>, <Data (Byte)>
PokeInt <CPU Address>, <Data (Word)>
PokeLong <CPU Address>, <Data (Long)>
Description: Sets the contents of <CPU Address> to <Data>. Used for more advanced tricks.
Back to the ABC Command Index

Command_BRIGHTEN:
Syntax: Brighten <palette>, <color entry>, <increment>, <delay>, <count>
Description: Increases the color intensity of a single color entry. <palette> and <color entry> define which color entry to brighten. <increment> is a color code. <increment> is what the routine uses to increase the intensity. For example, if the color code of a defined entry was gray (0x040404), and the brighten command is used with an increment of 0x000002, then the resulting color after one loop will be 0x040406. <delay> is the number of 16.67 ms to delay each time the entry is incremented (Same delay as the Sleep command). <count> is the number of times to brighten the entry. One unit of <count> is equal to one increment.
Back to the ABC Command Index

Command_DARKEN:
Syntax: Darken <palette>, <color entry>, <decrement>, <delay>, <count>
Description: Decreases the color intensity of a single color entry. <palette> and <color entry> define which color entry to brighten. <decrement> is a color code. <decrement> is what the routine uses to decrease the intensity. For example, if the color code of a defined entry was gray (0x040404), and the darken command is used with an decrement of 0x000002, then the resulting color after one loop will be 0x040406. <delay> is the number of 16.67 ms to delay each time the entry is decremented (Same delay as the Sleep command). <count> is the number of times to brighten the entry. One unit of <count> is equal to one decrement.
Back to the ABC Command Index

Command_HBLANK:
Syntax: HBlank <number of scanlines>
Description: Used for determining the scanline count for which a horizontal blank interrupter occurs. <number of scanlines> is a number 0 to 222 determining how many scanlines +1 will be counted until an interrupter is triggered, for one screen. For example, if the number of scanlines were set to 24, then the horizontal interrupt will occur every 25 scanlines, or 8 times during the the active display period (TC is composed of 224 lines, 224/25=8, to be conservative). Each horizontal blank is approximately 14.6 usec long, and each scan line is approximately 64.0 us long. A value of 0 is not recommended, unless you don't utilize the verticle blank interrupter (a value of 0 means a horizontal interrupter will occur every line). On the real system, the verticle blank interrupter will never occur if used with a value of 0.
Back to the ABC Command Index

Command_PALETTES:
Syntax: Palettes <data label>, <palette number>, <color nentry>, <count>, [Data Label Offset]
Description: Loads more than one color into color RAM. <data label> is a data label that marks were the data starts. The data statements must use the command DataInt for defining color codes. See the Palette command for details on color codes. You can't use the RGB function in data statements, so all color codes need to be constants. <palette number> is the palette number, ranging from 0 to 3. <color nentry> is the color entry within the color palette, ranging from 0 to 15. <count> is the number of color entries to load. One unit of <count> equals one color entry.
Back to the ABC Command Index

Command_ASM:
Syntax: Asm "<Instruction> [operand 1], [operand 2]"
Description: Inserts assembly code directly into the assembler output of the BASIC file. The expression must be in quotes, and the expression cannot be in a variable/string.
Back to the ABC Command Index

Command_LIBRARY:
Syntax: Library <filename>
Description: Includes an assembly library into compilation. The functions in the library will have to be called by command Call, or function Call()/Call&(). These calling commands/functions will jump directly to the label that you specified for your routine. Assembler errors will be displayed whenever an error occurs, so you can fix. See the corresponding call command/function for details on the requirements of assembly routines. The file must be located in the directory slibrary, inside the directory of the compiler's executable (eg: C:\basiegaxorz\slibrary, if the compiler is located in basiegaxorz).
Back to the ABC Command Index

Command_CALL:
Syntax: Call <routine label>, [argument 1], [argument 2],....., [argument n]
Description: Calls a user defined assembly routine. <routine label> is the label of the routine that you defined. The label can be anything, except for some keywords already taken by the compiler's own code. All routines must end with a rts instruction to continue execution.
Arguments: The arguments passed to the routine are stored onto the heap. The begining of the heap is pointed to with register A5. The heap works from lower addresses to higher addresses. Arguments are pushed onto the stack from left to right on the line where the Call command is being executed. If an argument is an integer, or long, the value of the expression is stored onto the stack as a 4 byte long number. If an argument is a string, the whole solved string is pushed onto the heap, from left to right, and is terminated with a null (0). If the address ended by pushing a string is an odd number, then an extra null (0) is added. After an argument is pushed onto the heap, the nest argument is pushed onto the stack right after the last one.
Registers: All data registers D0-D7 can freely be changed by the routine. Address registers A0-A4 can be freely used also. A5 is reserved to hold the heap pointer. A6 is reserved to hold the data pointer. A7 is reserved to hold the stack pointer.
Implementing BASIC Labels: All BASIC labels and number lines all begin with __LABEL_, and are followed by the label specified.
Implementing BASIC Variables: All BASIC integers begin with __INTEGER_, and are followed by the variable name specified. All BASIC longs begin with __LONG_, and are followed by the variable name specified. All BASIC strings begin with __STRING_, and are followed by the variable name specified.
Back to the ABC Command Index

Command_PSG:
Syntax: Psg <Channel>, <Data>
Description: Plays a frequency, or changes noise parameters for a PSG sound channel. <Channel> is the channel, ranging from 0 to 3. Channels 0 to 2 are the tone channels, and channel 3 is the noise generator. <Data> is a 10-bit frequency for a tone channel. If the channel is the noise generator, then <Data> has these parameters:
Noise Generator
MSB: 0 0 0 0 0 FB NF1 NF0 :LSB
FBNoise type
0Periodic (like low-frequency tone)
1White (hiss)
NF1 NF0 Noise Generator Clock Source
0 0 Clock/2 [Higher pitch, "less coarse"]
0 1 Clock/4
1 0 Clock/8 [Lower pitch, "more coarse"]
1 1 Tone Generator #3
Notes to Frequency to PSG Conversion Table
Note PSG Hertz Note PSG Hertz
A 3 7 110.00 B 5 798 493.88
A# 3 64 116.54 C 6 810 523.25
B 3 118 123.47 C# 6 822 554.37
C 4 169 130.81 D 6 834 587.33
C# 4 217 138.59 D# 6 844 622.25
D 4 262 146.83 E 6 854 659.26
D# 4 305 155.56 F 6 864 698.46
E 4 345 164.81 F# 6 873 739.99
F 4 383 174.61 G 6 881 783.99
F# 4 419 184.99 G# 6 889 830.61
G 4 453 195.99 A 6 897 880.00
G# 4 485 207.65 A# 6 904 932.32
A 4 516 220.00 B 6 911 987.77
A# 4 544 233.08 C 7 917 1046.5
B 4 571 246.94 C# 7 923 1108.7
C 5 596 261.63 D 7 929 1174.7
C# 5 620 277.18 D# 7 934 1244.5
D 5 643 293.66 E 7 939 1318.5
D# 5 664 311.13 F 7 944 1396.9
E 5 685 329.63 F# 7 948 1480.0
F 5 704 349.23 G 7 953 1568.0
F# 5 722 369.99 G# 7 957 1661.2
G 5 739 391.99 A 7 960 1760.0
G# 5 755 415.31 A# 7 964 1864.7
A 5 770 440.00 B 7 967 1975.5
A# 5 784 466.16 C 8 971 2093.0
Middle C = 261.63Hz = C 5
Back to the ABC Command Index

Command_PSGVOL:
Syntax: PsgVol <Channel>, <Volume>
Description: Changes the volume of a PSG sound channel. <Channel> is the channel, ranging from 0 to 3. <Volume> is the volume, ranging from 0 to 7, were 0 is mute, and 7 is the maximum volume.
Back to the ABC Command Index

Command_HALT:
Syntax: Halt
Description: Pauses execution until the TV enters the horizontal blanking period. Interrupters are still executed during the pause period.
Back to the ABC Command Index

Command_VALT:
Syntax: Valt
Description: Pauses execution until the TV enters the verticle blanking period. Interrupters are still executed during the pause period.
Back to the ABC Command Index

Command_DALT:
Syntax: Dalt
Description: Pauses execution until the TV enters the active display region of the screen. Interrupters are still executed during the pause period.
Back to the ABC Command Index

Command_TRAPCPU:
Syntax: TrapCPU
Description: Breaks execution at that line. Almost like a breakpoint, but not all that equivalent. When a breakpoint is encountered, all execution is stopped, and text is displayed at the bottem indicating that a breakpoint has occured, the line at which the TrapCPU command was placed, and a query to either return to normal program execution, or to restart execution. Pressing button START on joystick #1 will return execution. Pressing button C will reset execution.
Back to the ABC Command Index

Command_INPUT:
Syntax: Input [Optional String Text],<Variable Name>,...
Description: Gets user input. Input is stored onto the string, or integer, or long variable. The Inputting proceedure follows the "password style" way of entering values from a controller. The UP and DOWN buttons change the character. The A button places that character onto the line. The B button erases the last character from the line. The C button switches between upper and lower case letters. The START button ends user input, and takes whatever was entered in. Interrupts are still executed during the time the user is entering stuff. If [Optional String Text] is used, then a question mark will not appear automatically in the prompt. If [Optional String Text] is ommited, then a variable can just be placed in immediately to act as the input variable.
Back to the ABC Command Index

Command_WAITPADUP:
Syntax: WaitPadUp <Controller Number>
Description: Pauses execution until all the buttons on a controller are released. <Controller Number> is the controller number, starting with 0. A value of 0 is actually joystick #1, a value of 1 is joystick #2, and a value of 2 is the extension on Genesis model 1's. Interrupters are still executed during the pause period.
Back to the ABC Command Index

Command_BGCOLOR:
Syntax: BGColor <Palette>, <Entry>
Description: Sets the back drop color palette entry for the screen. The back drop color is the color that is placed behind all planes where entry 0 is used. Eg: the back drop color is the background color for text. <Palette>, <Entry> specify which color palette entry to use. <Palette> has a range from 0 to 3 and <Entry> has a range from 0 to 15.
Back to the ABC Command Index

Command_FREEALLSPRITES:
Syntax: FreeAllSprites
Description: Clears all displayed sprites, and resets all sprite handles to nothing, like when the Sega goes through a hardware reset.
Back to the ABC Command Index

Command_SETTEXTPLANE:
Syntax: SetTextPlane <SCROLL_A/SCROLL_B/WINDOW>
Description: Sets the drawing plane for all ASCII text commands. The SCROLL_B plane has the lowest display priority of all planes. Sprites will always have the highest priority. SCROLL_A will overlap SCROLL_B. The window plane then overlaps SCROLL_A.
Back to the ABC Command Index

Command_SETGFXPLANE:
Syntax: SetGFXPlane <SCROLL_A/SCROLL_B/WINDOW>
Description: Sets the drawing plane for all tile drawing commands. The commands included are: DrawTile, DrawTiles. The SCROLL_B plane has the lowest display priority of all planes. Sprites will always have the highest priority. SCROLL_A will overlap SCROLL_B. The window plane then overlaps SCROLL_A.
Back to the ABC Command Index

Command_WINDOWPROP:
Syntax: WindowProp <LEFT/RIGHT>, <UP/DOWN>, <Width>, <Height>
Description: Displays the window, and sets its view properties. <LEFT/RIGHT> determines if the window will be alligned to the left side of the screen, or the right. <UP/DOWN> determines if the window will be alligned to the top of the screen, or the bottem. <Width> and <Height> designate how large the window should be. The window overlaps anything over scroll A and scroll B.
Back to the ABC Command Index

Command_PUTS:
Syntax: Puts <Screen Position>, <Expression 1>;<Expression 2>,......
Description:Prints characters onto the screen at <Screen Position>. Unlike the Print command, Puts doesn't use the Cursor for text position, and it ignores any tabs and carriage returns, and display wrapping, and display scrolling. <Screen Position> is the location to place the text. One unit of <Screen Position> equals one 8x8 cell. 64 units of <Screen Position> equals one horizontal line. When <Screen Position> is divided by 64, the remainder of that number determines which verticle cell the text will be positioned on. Here's the formula: <Screen Position>=Row*64+Column. If a semi colon is encountered between text expressions, then leading characters will be directly displayed appended to the last. The PUTS command uses the same text plane as the PRINT command, or any other text command. The display plane can be changed by using the command SETTEXTPLANE.
Back to the ABC Command Index

Command_SCROLL2:
Syntax: Scroll2 <UP/DOWN/LEFT/RIGHT>, [Value], [Entry]
Description: Scrolls a background plane. <UP/DOWN/LEFT/RIGHT> is the direction to scroll to. [Value] is the number to set the scroll quantity to. As [Value] increases, scrolling shifts to the left, or upwards. As [Value] becomes negative, scrolling shifts to the right, or downwards. If [Value] is ommitted, then the scrolling value becomes 0. [entry] is the scroll entry. If the scroll mode for a direction is HSCROLL_OVERALL or VSCROLL_OVERALL, then [entry] can be ommited. If the scroll mode for a direction is HSCROLL_CELL then [entry] specifies which horizontal cell will be scrolled, where one unit of [entry] equals 8 horizontal lines (in pixels).If the scroll mode for a direction is HSCROLL_LINE then entry specifies which horizontal line will be scrolled, where one unit of [entry] equals one pixel high line. If the scroll mode for a direction is VSCROLL_2CELL then entry specifies which verticle line will be scrolled, where one unit of [entry] equals a width of two cells (two cells equals 16 pixels). The Scroll command does not scroll sprites along with the background plane. Sprite will have to be shifted manually, if desired.
Back to the ABC Command Index

Command_SETSCROLLMODE:
Syntax: SetScrollMode <HSCROLL_OVERALL/HSCROLL_CELL/HSCROLL_LINE>, <VSCROLL_OVERALL/VSCROLL_2CELL>
Description: Sets the scrolling mode. If HSCROLL_OVERALL is used, then when the screen is scrolled horizontally, the entire plane is scrolled. If HSCROLL_CELL is used, then when the screen is scrolled horizontally, 1 horizontal cell gets scrolled. If HSCROLL_LINE is used, then when the screen is scrolled horizontally, 1 horizontal line gets scrolled. If VSCROLL_OVERALL is used, then when the screen is scrolled verticle, the entire plane is scrolled verticle. If VSCROLL_2CELL is used, then when the screen is scrolled verticle, 2 verticle cell gets scrolled. Note: when VSCROLL_2CELL is used, both planes SCROLL_A and SCROLL_B will be scrolled together.
Back to the ABC Command Index

Command_SETSCROLLPLANE:
Syntax: SetScrollMode <SCROLL_A/SCROLL_B>
Description: Sets the plane to scroll.
Back to the ABC Command Index

Command_CONTINUEWHILE:
Syntax: Continue While
Description: Interrupts the normal flow of execution in a while loop. The Continue While statement skips all the following statements in the body loop and triggers the next itteration of the loop. This technique can be of use within complex loops where you might wish to skip the next loop iteration from various locations.
Back to the ABC Command Index

Command_CONTINUEFOR:
Syntax: Continue For
Description: Interrupts the normal flow of execution in a for loop. The Continue For statement skips all the following statements in the body loop and triggers the next itteration of the loop. This technique can be of use within complex loops where you might wish to skip the next loop iteration from various locations.
Back to the ABC Command Index

Command_CONTINUEDOLOOP:
Syntax:
Continue Do
Continue Loop
Description: Interrupts the normal flow of execution in a Do/Loop loop. The Continue For statement skips all the following statements in the body loop and triggers the next itteration of the loop. This technique can be of use within complex loops where you might wish to skip the next loop iteration from various locations.
Back to the ABC Command Index

Command_EXITWHILE:
Syntax: Exit While
Description: Interrupts and terminates a While loop immediately. This technique can be of use within complex loops where you might wish to skip the next loop iteration in various locations.
Back to the ABC Command Index

Command_EXITFOR:
Syntax: Exit For
Description: Interrupts and terminates a For loop immediately. This technique can be of use within complex loops where you might wish to skip the next loop iteration in various locations.
Back to the ABC Command Index

Command_EXITDOLOOP:
Syntax:
Exit Do
Exit Loop
Description: Interrupts and terminates a Do/Loop loop immediately. This technique can be of use within complex loops where you might wish to skip the next loop iteration in various locations.
Back to the ABC Command Index

Command_REGMOVE.B:
Command_REGMOVE.W:
Command_REGMOVE.L:

Syntax: RegMove.X <Source>,<Destination>
Description: Copies a 68k register into a BASIC variable, for use with a lower level language. The register names are D0....D7, and A0....A7. The source or destination can either be a 68k register or a BASIC expression, but cannot be both at any same time. Like the assembly Move instruction, the RegMove.X statement will not truncate any registers if the size of the data transfter is a byte of word.
Back to the ABC Command Index

Command_GETS:
Syntax: Gets <Variable>
Description: Gets user input and stores it in a variable. The gets command is cheap compared to the Input command, no sprite for a cursor, no carriage returns, no output text, etc., so its really crude entering values. Interrupts are still executed during the time the user is entering stuff.
Back to the ABC Command Index

Command_SLEEP2:
Syntax: Sleep2 <Integer Expression>, [TVBLANK]
Description: Pauses execution for one horizontal blank for every unit of the Expression. The period for the horizontal blank is approximately 64 uSec (One Sec is 1,000,000 uSec!!!). If the TVBLANK keyword is present in the second argument, the sleep command ends at the begining of the horizontal blank (Good for color rasters). By default, when TVBLANK is not present, the sleep command will end sleeping time at the begining of the displaying period.
Back to the ABC Command Index

Command_INCASM:
Syntax: IncAsm <filename>
Description: Includes an assembly library into compilation. The functions in the library will have to be called by command Call, or function Call()/Call&(). These calling commands/functions will jump directly to the label that you specified for your routine. Assembler errors will be displayed whenever an error occurs, so you can fix. See the corresponding call command/function for details on the requirements of assembly routines.
Back to the ABC Command Index

Command_TVSET:
Syntax: TVSet <TV Type>
Description: Sets NTSC 60hz or PAL 50hz video drawing mode. By default, all programs start out as NTSC. If <TV Type> is 0, NTSC is selected. If <TV Type> is 1, PAL is selected
Back to the ABC Command Index

Command_FAKE:
Syntax: Fake <Fake Data Label>,<Variable>
Description: Converts a variable address into a data label. <Fake Data Label> is a new data label to create that will point to the variable. <Variable> is the variable. If the variable is an array, an element must be defined first. This command is useful for loading tiles that reside in variable, where the LoadTiles command requires a data label. It is also good for interpreting data inside variable without direct variable usage.
Back to the ABC Command Index

Command_VDPRAMWRITE:
Syntax: VdpRamWrite <RAM Address>,<Data>
Description: Writes data into VRAM. <RAM Address> is the address (has to be EVEN), it can be integer, or long. <Data> is the data to write to that address. VRAM is 64 kilobytes big, and writes to the VRAM are all 2 bytes long. ODD addresses cannot be accessed, and individual byte writes are not permitted.
Back to the ABC Command Index

Command_MEMCOPY:
Syntax: MemCopy <Source Data Label>,<Destination Data Label>,<Size>
Description: Copies memory from <Source Data Label> to <Destination Data Label>. <Size> is the number of bytes that will be copied. Copying speed is dependent upon EVEN, or ODD addresses (EVEN being the fastest), and the size of the block to copy.
Back to the ABC Command Index

Command_FASTTILECOPY:
Syntax: FastTileCopy <Source Data Label>,<Destination Data Label>,<Number of tiles>
Description: Copies memory from <Source Data Label> to <Destination Data Label>. Almost the same as MemCopy, but uses faster copying code. <Number of tiles> is the number of 8*8 tiles that will be copied. One unit of <Number of tiles> is equal to one 8*8 tile, or 32 bytes.
Back to the ABC Command Index

Command_DRAWTILESOVR:
Syntax: DrawTilesOvr <label>, <tile vram offset>, <x>, <y>, <width>, <height>, [Data Label Offset]
Description: Just like the DrawTiles command, except this command does not overwrite any tile that has a source tile of 0. Example: If a game map has the number 0 in it, and DrawTilesOvr was used to draw this map, the 0 will not be written to VRAM, and the tiles drawn before will reamin unchanged. See the DRAWTILES command for arguments, and details.
Back to the ABC Command Index

Command_DRAWTILESINC:
Syntax: DrawTilesInc <tile vram offset>, <x>, <y>, <width>, <height>
Description: Draws one or more tiles on the screen at <X> and <Y> that is <Width> and <Height> big. One unit of X, Y, Width, or Height is equal to one 8*8 cell. X and Y start at (0,0), and that is the very upper left part of the screen. <Tile VRAM Offset> is the tile number that will be drawn. One unit of this is equal to one 8*8 tile. Just like the DrawTiles command, but this one doesn't use any data labels. Instead, it starts drawing using the data from <tile vram offset>, and incrementing it by 1 for each tile drawn. Drawing starts from the left, then goes to the right. When it reaches the maximum width, the command will then move the drawing cursor down, and then start drawing from the left to right again.
Back to the ABC Command Index

Command_DRAWTILESINC2:
Syntax: DrawTilesInc <tile vram offset>, <x>, <y>, <width>, <height>
Description: Draws one or more tiles on the screen at <X> and <Y> that is <Width> and <Height> big. One unit of X, Y, Width, or Height is equal to one 8*8 cell. X and Y start at (0,0), and that is the very upper left part of the screen. <Tile VRAM Offset> is the tile number that will be drawn. One unit of this is equal to one 8*8 tile. Just like the DrawTiles command, but this one doesn't use any data labels. Instead, it starts drawing using the data from <tile vram offset>, and incrementing it by 1 for each tile drawn. Drawing starts from the top, then draws going down. When it reaches the maximum height, the command will then move the drawing cursor right, and then start drawing top to bottem again.
Back to the ABC Command Index

Command_CONST:
Syntax: Const #Constant Name=Constant Value
Description: Defines a constant. All constants begin with a #. A constant must first be defined before it can be used.
Back to the ABC Command Index

Command_INCLUDE:
Syntax: Include <File Name>
Description: Includes another BASIC source code into the source code. Includes cannot be nested, and this command is still very buggy, and will be buggy for a long time.
Back to the ABC Command Index

Command_Write:
Syntax: Write <Expression 1>,<Expression 2>,........
Description: Like the read command, but does the opposite. It writes data to Data commands. The data that is written is only temporary, when the unit is turned off, the data is lost. This command can be used by both a Sega CD Master Program, and a regular Sega CD Program.
Back to the ABC Command Index

Command_WriteInt:
Syntax: WriteInt <Expression 1>,<Expression 2>,........
Description: Like the read command, but does the opposite. It writes data to Data commands. The data that is written is only temporary, when the unit is turned off, the data is lost. This command can be used by both a Sega CD Master Program, and a regular Sega CD Program.
Back to the ABC Command Index

Command_WriteLong:
Syntax: WriteLong <Expression 1>,<Expression 2>,........
Description: Like the read command, but does the opposite. It writes data to Data commands. The data that is written is only temporary, when the unit is turned off, the data is lost. This command can be used by both a Sega CD Master Program, and a regular Sega CD Program.
Back to the ABC Command Index

Command_WriteP:
Syntax: WriteP <Variable Name>, <Value to write into variable>
Description: Writes data into ram that is 8-bits in size. WriteP (stands for Write-Peripheral) is mostly used to external battery bakup ram that is provided on the game cartridge. WriteP handles data differently compared to normal storage operations (eg: ext_a = 1234 ' Won't work in external ram unless the ram is 16-bits). The first argument specifies the variable to write into. If this variable is not declared, and is not an array, then the compiler will declare the variable automatically. The second parameter is the actual value to write into the external ram space.
Back to the ABC Command Index

Command_LOCAL:
Syntax: Local <Variable>(Dimmensions) As <Variable Type> [* <String Size>] [At <Location>], <Variable>(Dimmensions) As <Variable Type> [* <String Size>] [At <Location>], ...
Descrition: Dimensions a local variable. The variable declared can either be local to the main loop, or for the current function, depending on where the statement is placed. Everything else is the same as the DIM statement. The purpose of this command is to deny access to local variables outside the scope where it was defined.
Back to the ABC Command Index

Command_GLOBAL:
Syntax: Global <Variable>(Dimmensions) As <Variable Type> [* <String Size>] [At <Location>], <Variable>(Dimmensions) As <Variable Type> [* <String Size>] [At <Location>], ...
Descrition: Dimensions a global variable. The variable declared will be able to be accessed anywhere in your program, even if it is out of the scope of the current procedure. These is also an option (see the OPTION command for details) to make all variables declared with DIM global.
Back to the ABC Command Index

Command_FONTPAL:
Syntax: FontPal [Foreground Color RGB], [Background Color RGB]
Description: This command automatically changes the color palette entries for text displayed with PRINT for you without having to calculate which color entry you want to change. The programmer doesn't need to know which color entry the font is using in palette memory (CRAM) in order to change the colors of the font. This command is totally different from the COLOR command, as in this command can change the actual RGB values. When changing the RGB color though, you risk changing the color of all the text on the screen (all the text that is printed with the same color).
Back to the ABC Command Index

Command_DOLOOP:
Syntax:
	Do [While / Until] <expression>
		... Instructions
		... Instructions
	Loop [While / Until] <expression>
Description: Similiar to Visual Basic's Do....Loop, this loop structure will keep repeating through the loop until a certain condition is reached. The programmer needs to place the keywords While, or Until after either Do or Loop to tell the compiler when to check for conditions. Use the While keyword to keep the loop repeating when the supplied expression is true. Use the Until keyword to stop the loop from repeating when the supplied expression becomes true. When the check condition is placed after DO, the compiler will place code to check for conditions at the begining of the loop. When the condition is places after LOOP, then the condition will be checked at the end of the loop. The loop can be exitted immediately using the command: EXIT LOOP. The command CONTINUE LOOP can be used also.
Back to the ABC Command Index

Command_SELECTCASE:
Syntax:
	Select Case <Variable>
		Case <Integer/Long Number>:
			... Instructions
			[Exit Select]
		Case <Integer/Long Number>:
			... Instructions
			[Exit Select]
		[Case Else:]
			[... Instructions]
			[Exit Select]
	End Select
Description: The select case instruction will jump to specific portions of your code (cases) based on the value inside the variable specified. The Select Case usage, and operation is totally different compared to other basic languages. Select Case in BaisEgaXorz uses a table to jump to certain locations, so only integer and long values can be used for the variable. Also, values inside your cases have to be in ascending order. If the programmer omits a value from the case (there is a gap in between cases), then when Select Case is executed, the program will jump to the last lowest case value. If the value is below the lowest case value, then the program will jump to the Case Else condition. Refer to examples on proper ways to use Select Case. Using Select Case in BasiegaXorz is very advanced, but when used correctly, it can be very rewarding because it can speed your program up very fast (compared to using 100 different If...Then statements). Whenever possible, don't use Select Case very often because of it's complexities, which can create bugs for many users.
Back to the ABC Command Index

Command_VIDMODE:
Syntax: VidMode <Mode Keyword>, ...
Description: Changes the drawing mode of Sega's VDP (video display processor). Valid video modes are: DOUBLEINTERLACE, INTERLACE, VID32CELL, VID40CELL. Modes can be mixed around, or not even used at all.
Back to the ABC Command Index

Command_LOADFONT:
Syntax: LoadFont [Font Data Label], <Number of tiles to load>, <Start Tile Number>
Description: Replaces the internal font in VDP vram with a user-specified font. The font is always in a 1-bit format, or each bit will represent one pixel. A bit value of 0 will draw the background color, and a value of 1 will draw the foreground. If the data label pointing to the font is ommitted, the default font from ROM will be loaded (the default font).
Back to the ABC Command Index

Command_WAITRASTER:
Syntax: <Scan line number>
Description: Pauses the program until the TV draws the scan-line specified by the programmer. Scan-line is an integer value. Using TVBLANK as the scan-line value will start execution exactly at the horizontal blank of the next scan-line.
Back to the ABC Command Index

Command_VIDATA:
Syntax: ViData <Constant 1>,<Constant 2>,........
Description: Inserts VRAM Initialization data into the basic program. This data cannot be read out like the DATA command. Any data going here is written directly to the VRAM at the startup of the program. Use the TILEORG command to change the tile address. Any data has to be byte-long (see DATAINT for 16-bit data, and DATALONG for 32-bit). VRAM initialization data is particularly useful for RAM games to reduce the executable size. VRAM initialization data also works for other compilations (ROM based games, Sega CD, etc) too.
Back to the ABC Command Index

Command_VIDATAFILE:
Syntax: ViDatafile <Data File>,[BIN]
Description: Inserts data from an external file into VRAM Initialization space. <Data File> has to be a file inside the compiler directory. When keyword BIN is used, the file will be included as a binary file. Example: Datafile Levels.dat,BIN. If BIN is left out, then the file will be included as a text. Proper text file syntax (same as assembler):
dc.b <Byte Constants 1>,<Byte Constants 2>......
dc.w <Word Constants 1>,<Word Constants 2>......
dc.l <Long Constants 1>,<Long Constants 2>......
Back to the ABC Command Index

Command_TILEORG:
Syntax: TileOrg <Tile Number>
Description: Changes the current tile number for the VIDATA, VIDATAINT, VIDATALONG, VIDATAFILE instructions. The tile number is a number from 0 to 2047. The system font occupies tiles 0 - 255. To disable the loading of the system font, use the OPTION NoLoadFont option.
Back to the ABC Command Index

Sega CD Specific Commands
Note: All commands have to have a space/tab in front. Sega CD specific commands can only be used on projects that are compiled as a Sega CD boot ISO, or a Sega CD Program (except for some commands).
CDPLAY
CDPLAY2
CDSTOP
ADDSCD
LOADSCD
LOADSCD (For Loading VRAM Data)
LOADSCD (For Loading Data Into Variables)
LOADSCD (For Loading Data Into Memory)
CDPAUSE
CDUNPAUSE

Command_CDPLAY:
Syntax: CDPlay <Track Number>
Description: Plays an audio track. The audio track is not played repeatedly. <Track Number> is the track number to play. Track number 1 is the data track that holds all the game info. Tracks above that are your audio tracks. Eg: In an emulator, if you have one of your tracks names as basic 02.mp3, to play that track, you will need to use CDPlay 2. This command can be used by both a Sega CD Master Program, and a regular Sega CD Program.
Back to the Sega CD Index

Command_CDPLAY2:
Syntax: CDPlay2 <Track Number>
Description: Plays an audio track. The audio track is played repeatedly. <Track Number> is the track number to play. Track number 1 is the data track that holds all the game info. Tracks above that are your audio tracks. Eg: In an emulator, if you have one of your tracks names as basic 02.mp3, to play that track, you will need to use CDPlay 2. This command can be used by both a Sega CD Master Program, and a regular Sega CD Program.
Back to the Sega CD Index

Command_CDSTOP:
Syntax: CDStop
Description: Stops playing an audio track. This command can be used by both a Sega CD Master Program, and a regular Sega CD Program.
Back to the Sega CD Index

Command_ADDSCD:
Syntax: AddSCD <Filename>
Description: This command adds a file to the list of programs that will be included onto the CD. This command can only be used in a Sega Boot CD Master Program (compiler output option: Compile as a Sega Boot CD. The file must be a pre-compiled Sega CD Program (extension .SCD). The compiler will not compile the Sega CD Program from the Master CD Program. Files are added from first to last. When it comes to loading these programs, the very first program added will have a cluster number of 2. The second file that is loaded after a previous AddSCD command will have a cluster number of 3, and if another file is added, its cluster number will be 4, etc etc. Cluster 1 is the Master Sega CD program. This is the program that is compiled as a Sega Boot CD. Cluster 0 is the CD Boot section.
Back to the Sega CD Index

Command_LOADSCD: (For Loading Sega CD Programs)
Syntax: LoadSCD <Cluster>
Description: This command kills execution of the current program and loads another program and runs it. When loading programs, the very first program added by AddSCD will have a cluster number of 2. The second file that is loaded by AddSCD after a previous AddSCD command will have a cluster number of 3, and if another file is added, its cluster number will be 4, etc etc. Cluster 1 is the Master Sega CD program. This is the program that is compiled as a Sega Boot CD. Cluster 0 is the CD Boot section. This command can be used by a Sega CD Master Program, and a regular Sega CD Program.
Back to the Sega CD Index

Command_LOADSCD: (For Loading VRAM Data)
Syntax: LoadSCD <Cluster>, <VRAM>, <Start Position*32>, <VRAM Destination*32>, <Number of tiles to copy>
Description: This command kills copies data from a cluster on a CD, and then stores it into VRAM. Mainly, this command is used to load tiles into VRAM. All parameters have to be aligned by 32 bytes (hence, a single tile is 32 bytes long). You'll have to create your own way to generate the cluster data.
Back to the Sega CD Index

Command_LOADSCD: (For Loading Data Into Variables)
Syntax: LoadSCD <Cluster>, <ARRAY>, <Start Position>, <Variable>
Description: This command loads data from a cluster on the CD, and then stores it into a variable, or an array. <Start Position> specifies the location within the cluster in which LOADSCD will load data into the variable. The number of bytes that are read are pre-determined by the compiler (based on the actual size of the variable or array). Putting data into the right places, and then creating an address to retrieve them is tricky. More than likely, you'll probably use a hex editor to create your data. I'll try to make a utility later that will generate clusters based on a script or something.
Back to the Sega CD Index

Command_LOADSCD: (For Loading Data Into Memory)
Syntax: LoadSCD <Cluster>, <POINTER>, <Start Position>, <Memory Destination>, <Number of Bytes>
Description: This command loads data from a cluster on the Sega CD, and then stores the data into memory on the main Sega Genesis. <Start Position> is a LONG value that specifies which byte in the cluster the programmer wants to start copying data from. This instruction is good for loading huge chunks of data into Word RAM (where your program executes). For example, the programmer can point the Destination Address to a data statement, where the LOADSCD command can load new data into that data space.
Back to the Sega CD Index

Command_CDPAUSE:
Syntax: CDPAUSE
Description: When a CD audio track is playing, the play can be paused by using this command.
Back to the Sega CD Index

Command_CDUNPAUSE:
Syntax: CDUNPAUSE
Description: Unpauses a paused-playing CD audio track.
Back to the Sega CD Index

Functions
Joypad()
Peek()
PeekInt()
PeekLong&()
RGB()
AddSprite()
Rnd()
SpritePosX()
SpritePosY()
Val()
Left$()
Right$()
Mid$()
Str$()
Hex$()
Bin$()
String$()
VarPtr&()
Call()
Call&()
TVScanX()
TVScanY()
Len()
DataPtr&()
Chr$()
ChrW$()
ChrL$()
Asc()
AscW()
AscL&()
Not()
Not&()
LblPtr&()
EndCode&()
StartCode&()
HFlipTile()
VFlipTile()
Palette()
Priority()
VdpRamRead()
TvType()
UnitType()
ReadTile()
PosX()
PosY()
CurInk()
Read()
ReadInt()
ReadLong&()
ReadP()
VBlankOn()
HBlankOn()
Functions In Alphabetical Order
AddSprite()
Asc()
AscW()
AscL&()
Bin$()
Call()
Call&()
Chr$()
ChrW$()
ChrL$()
CurInk()
DataPtr&()
EndCode&()
HBlankOn()
Hex$()
HFlipTile()
Joypad()
LblPtr&()
Left$()
Len()
Mid$()
Not()
Not&()
Palette()
Peek()
PeekInt()
PeekLong&()
PosX()
PosY()
Priority()
Read()
ReadInt()
ReadLong&()
ReadP()
ReadTile()
RGB()
Right$()
Rnd()
SpritePosX()
SpritePosY()
StartCode&()
Str$()
String$()
TVScanX()
TVScanY()
TvType()
UnitType()
Val()
VarPtr&()
VBlankOn()
VdpRamRead()
VFlipTile()

Function_JOYPAD():
Syntax: Integer=JOYPAD(<Joypad Number>)
Description: Return the keypress state of a Joypad. Joystick 1 is specified by a <Joypad Number> value of 0, and joystick 2 is specified by a <Joypad Number> value of 1. A button pressed is indicated by a 1 in its bit.
JoyPad Values
BitHexDecimalButton
0 &h0011 Up
1 &h0022 Down
2 &h0044 Left
3 &h0088 Right
4 &h01016 B
5 &h02032 C
6 &h04064 A
7 &h080128 Start
8 &h100256 Z (6-Button)
9 &h200512 Y (6-Button)
10 &h4001024 X (6-Button)
11 &h8002048 Mode (6-Button)
3 Button and 6 Button Joystick Note
When using a 3-button controller, you cannot assume that the 6-button bits will be cleared. The 6-button bits are randomly (actually they're relevent to the buttons pressed but blah) set or cleared when using a 3 button joystick, so the joypad function will not always read out the exact deciaml/hex value listed above.
Back to the ABC Functions Index

Function_PEEK():
Function_PEEKINT():
Function_PEEKLONG():
Syntax:
Integer=PEEK(<address>)
Integer=PEEKINT(<address>)
Long=PEEKLONG&(<address>)

Description: Reads a value in memory. <Address> is a long value that holds the address to fetch data in memory. The Peek() function reads a byte, PeekInt() reads a word, and PeekLong&() reads a long.
Back to the ABC Functions Index

Function_RGB():
Syntax: Integer=RGB(<red>, <green>, <blue>)
Description: Converts red, green, and blue components into a color code for the VDP. The components range from 0 to 7, as 0 being the darkest, and 7 being the most intense. This makes a maximum of 512 colors, which is the max for Sega's VDP.
Back to the ABC Functions Index

Function_ADDSPRITE():
Syntax: Integer=AddSprite(<height>, <width>)
Description: Creates a new sprite to be displayed. Width and Height determine the size of the sprite, and ranges in values from 0 to 3. One unit equals one 8*8 cell (sprite sizes range from 8*8 to 32*32). Sprite sizes cannot be changed once the sprite is created. Returns the sprite number handle that is used for other sprite routines.
Back to the ABC Functions Index

Function_RND():
Syntax: Integer=RND(<random range>)
Description: Returns a random number. <random range> specifies the maximum value to return, and starts from 1 to 65535. Use the Randomize command to make sure a unique value is returned from RND.
Back to the ABC Functions Index

Function_SPRITEPOSX():
Syntax: Integer=SpritePosX(<sprite number>)
Description: Returns the verticle position of a sprite. <sprite number> is the handle of the sprite.
Back to the ABC Functions Index

Function_SPRITEPOSY():
Syntax: Integer=SpritePosY(<sprite number>)
Description: Returns the horizontal position of a sprite. <sprite number> is the handle of the sprite.
Back to the ABC Functions Index

Function_VAL():
Syntax: Integer or Long=Val(<string expression>)
Description: Converts a string number into an integer or long number.
Back to the ABC Functions Index

Function_LEFT():
Syntax: String=Left$(<string expression>, <length>)
Description: Returns a string that comprises the left-most characters of a string. <string expression> is the string to be extracted from. <length> is the number of characters to extract.
Back to the ABC Functions Index

Function_RIGHT():
Syntax: String=Right$(<string expression>, <length>)
Description: Returns a string that comprises the right-most characters of a string. <string expression> is the string to be extracted from. <length> is the number of characters to extract.
Back to the ABC Functions Index

Function_MID():
Syntax: String=Mid$(<string expression>, <start>, [length])
Description: Returns a string within another string. <string expression> is the source string to get the characters from. <start> is the start position of the source string to start copying from. <start> begins at 0 for the 1st character. [length] is the length of the string that will be returned. If [length] is ommited, then the maximum number of characters will be returned.
Back to the ABC Functions Index

Function_STR():
Syntax: String=Str$(<non-string expression>)
Description: Converts a non-string number into a string.
Back to the ABC Functions Index

Function_HEX():
Syntax: String=Hex$(<number>)
Description: Converts a long number into a string, formatted in hex. The length of the string is 8 characters, for a 32-bit number. Use string parsing functions to concave down.
Back to the ABC Functions Index

Function_BIN():
Syntax: String=Bin$(<number>)
Description: Converts a long number into a string, formatted in binary. The length of the string is 32 characters, for a 32-bit number. Use string parsing functions to concave down.
Back to the ABC Functions Index

Function_STRING():
Syntax: String=String$(<character>, <length>)
Description: Returns a string whose characters all have the same specified character. <character> is a string were the first character is the character to use for filling the destination string. <length> is the length of the string to create.
Back to the ABC Functions Index

Function_VARPTR():
Syntax: Long=VarPtr&(<variable>)
Description: Gets the memory address of the variable.
Back to the ABC Functions Index

Function_CALL():
Syntax:
Integer=Call(<asm routine name>, [argument 1], [argument 2],...., [argument n])
Long=Call&(<asm routine name>, [argument 1], [argument 2],...., [argument n])
Description: Calls the assembly routine and returns its return value. <asm routine name> is the routine's label to call. The arguments are passed to the routine with the heap. The routine must store its return value in D0. See the Call command for more details.
Back to the ABC Functions Index

Function_TVSCANX():
Syntax: Integer=TVScanX()
Description: Returns the verticle position of the TV beam. This value is not valid during verticle blank. This value is copied directly from the VDP's HV counter.
Back to the ABC Functions Index

Function_TVSCANY():
Syntax: Integer=TVScanY()
Description: Returns the horizontal position of the TV beam. This value is not valid during verticle blank. This value is copied directly from the VDP's HV counter.
Back to the ABC Functions Index

Function_LEN():
Syntax: Integer=Len(<string expression>)
Description: Gets the length of a string. <string expression> is the string.
Back to the ABC Functions Index

Function_DataPtr&():
Syntax: Long=DataPtr&()
DataPtr&()=Long
Description: Reads the current value of the data pointer. One unit of DataPtr&() is one byte. Use DataPtr&=Expression to relocate the data pointer. For example, DataPtr&=DataPtr&()+1 will increase the data pointer by one byte. The previous line of code can actually be written as dataptr&++ also - immediate operators also work for setting the data pointer, eg: DataPtr&--.
Back to the ABC Functions Index

Function_Chr$():
Function_ChrW$():
Function_ChrL$():

Syntax:
String$=Chr$(<integer/long expression>)
String$=ChrW$(<integer/long expression>)
String$=ChrL$(<integer/long expression>)
Description: Converts the number expression into a string. For example, if the expression were to be &h61, then it would convert into the ASCII character A using chr$(). Word and long sized values can be created also. Note: when using ChrW$() or ChrL$(), if the place that the function is being placed is on an odd (2nd character, 4th character, etc) position in the string, a space will be inserted. This is due to the 68k's architecture.
Back to the ABC Functions Index

Function_Asc():
Function_AscW():
Function_AscL&():

Syntax:
Something=Asc(<string expression>)
Something=AscW(<string expression>)
Something&=AscL&(<string expression>)
Description: Converts a string into its real number. For example, to get the ASCII code for character A, you could use Print Asc("A"). This value can then be sent back to a function like Chr$() to convert the character A back.
Back to the ABC Functions Index

Function_Not():
Function_Not&():

Syntax:
Something=Not(<expression>)
Something&=Not&(<expression>)
Description: Returns the bit-wise inverse of the expression.
Back to the ABC Functions Index

Function_LblPtr&():
Syntax: Long=LblPtr&(<Data Label>)
Description: Returns the absolute address of the data label. This can be used when you want to know the address of some data label for assembly commands.
Back to the ABC Functions Index

Function_EndCode&():
Syntax: Long=EndCode&()
Description: Returns the absolute address of the end of code in the compiled basic program.
Back to the ABC Functions Index

Function_StartCode&():
Syntax: Long=StartCode&()
Description: Returns the absolute address of the start of code in the compiled basic program.
Back to the ABC Functions Index

Function_HFlipTile():
Syntax: Integer or Long=HFlipTile(<Flip Condition>)
Description: Flips a tile horizontally. This function is used by adding the value of this function to the tile number. If <Flip Condition> then the tile is not flipped. If it is 1 then it is flipped.
Back to the ABC Functions Index

Function_VFlipTile():
Syntax: Integer or Long=VFlipTile(<Flip Condition>)
Description: Flips a tile verticle. This function is used by adding the value of this function to the tile number. If <Flip Condition> then the tile is not flipped. If it is 1 then it is flipped.
Back to the ABC Functions Index

Function_Palette():
Syntax: Integer or Long=Palette(<Palette Number>)
Description: Changes the palette number of the tile being drawn. This function is used by adding the value of this function to the tile number. <Palette Number> is the palette number, eg 0,1,2, and 3.
Back to the ABC Functions Index

Function_Priority():
Syntax: Integer or Long=Priority(<Priority Condition>)
Description: Changes the condition of the prioirty of a drawn tile. This function is used by adding the value of this function to the tile number. If <Flip Condition> then the tile is drawn at lower priority. If it is 1 then the tile is drawn at higher priority.
Back to the ABC Functions Index

Function_VdpRamRead():
Syntax: Integer or Long=Priority(<Address>)
Description: Reads a word in VRAM. <Address> is an even address to read. VRAM is 64 kilobytes long. Returns a 16-bit, 2 byte value.
Back to the ABC Functions Index

Function_TvType():
Syntax: Integer or Long=TvType()
Description: Returns 0 if the designated system is an NTSC machine. Returns 1 if the designated system is a PAL machine.
Back to the ABC Functions Index

Function_UnitType():
Syntax: Integer or Long=UnitType()
Description: Returns 0 if the machine was released domestic. Returns 1 if the machine was released overseas. Domestic means Japan, and anywhere else would be overseas.
Back to the ABC Functions Index

Function_ReadTile():
Syntax: Integer or Long=ReadTile(<X>,<Y>)
Description: Reads the tile value in VRAM and returns it in 2-bytes (16 bit). X and Y are the coordinates, where one unit is equal to 8 pixels, or one tile.
Back to the ABC Functions Index

Function_PosX():
Syntax: Integer or Long=PosX()
Description: Reads the X value of the text cursor.
Back to the ABC Functions Index

Function_PosY():
Syntax: Integer or Long=PosY()
Description: Reads the Y value of the text cursor.
Back to the ABC Functions Index

Function_CurInk():
Syntax: Integer or Long=CurInk()
Description: Reads the drawing color palette value for text and graphics.
Back to the ABC Functions Index

Function_Read():
Syntax: Integer or Long=Read()
Description: Just like the Read command, but doesn't use any variables.
Back to the ABC Functions Index

Function_ReadInt():
Syntax: Integer or Long=ReadInt()
Description: Just like the ReadInt command, but doesn't use any variables.
Back to the ABC Functions Index

Function_ReadLong():
Syntax: Long=Readlong&()
Description: Just like the Readlong command, but doesn't use any variables.
Back to the ABC Functions Index

Function_ReadP():
Syntax: Integer or Long = ReadP(<Variable Name>)
Syntax: Long = ReadP&(<Variable Name>)
Syntax: String = ReadP$(<Variable Name>)
Description: Reads data from an 8-bit ram into a variable. ReadP (stands for Read-Peripheral) is mostly used to external battery bakup ram that is provided on the game cartridge. ReadP handles data differently compared to normal storage operations (eg: myvar = ext_a ' Won't work in external ram unless the ram is 16-bits). The first argument specifies the external ram variable to access data. When executed, the function will return the normalized value from the external ram variable.
Back to the ABC Command Index

Function_ReadScroll():
Syntax: Integer or Long = ReadScroll(<LEFT/RIGHT/UP/DOWN>, [Entry Number])
Description: Reads data from the video scrolling memory. This function can read both LEFT and RIGHT scrolling data, or UP and DOWN scrolling data, specified in the first argument. Depending on the scrolling mode that you are using, you will get different numbers returned (eg: 2 cell verticle scroll mode vs. scrolling the entire screen horizontally). You can specify the scrolling entry number in [Entry Number]. If the entry number is ommitted, then the first entry (entry number 0) will be returned.

Function_VBlankOn():
Syntax: Integer or Long = VBlankOn()
Description: Returns true when the program is in the verticle blanking portion of the video display. Good for when detecting if your code is in verticle blank or not.

Function_HBlankOn():
Syntax: Integer or Long = HBlankOn()
Description: Returns true when the program is in the horizontal blanking portion of the video display. Good for when detecting if your code is in horizontal blank or not. It's very likely that this function is useless in BasiEgaXorz because the program stays in horizontal blanking for a very short period (~16uS), making it hard for your program to detect when in horizontal blanking.

Operators
Operations are executed in the order from the level list (starting from level 1) below, and then are executed from left to right.
Order of Operations:
Data Types
Integer: Values: -32,768 to 65,535 (2 bytes long)
Long: Values: -2,147,483,648 to 2,147,483,647 (4 bytes long)
String: If not dimensioned, then the default fixed size for a string is 128 bytes (127 characters + Null). The default value of 128 can be changed with the command Option STRING_SIZE. I will not add in support for dynamic strings because they take too much execution time to use x.x. This version of BASIC is aimed for speed. If the string is dimensioned, then the number of characters it can hold is declared by you.

Arrays and Multi-Dimensional Arrays
Starting with version 0.40 of BasiEgaXorz, the compiler can now handle multi-dimensional arrays. Previous versions could only use arrays that were singal dimension, and there was very limited support for string arrays. An important note to make is that arrays have to be predimensioned prior to using them. The compiler won't dimension an array for you if you don't use the DIM statement. When dimensioning an array, be sure to keep in mind that the Sega Genesis has only 64KBytes of RAM memory to work with. BasiEgaXorz will use somewhere around 40-60 bytes to hold hardware registers, mode settings, and system settings. The Heap and Stack will also use some memory also for holding temporary values. An array can be simply dimensioned for integer, or long, or string data types using this syntax:

These arrays can be accessed like so:
		MyArray&(1,2,3) = 123456789
		Print MyArray&(1,2,3)
				
The compiler adds one more entry to the dimension of the array. For example, if you declared an array using DIM MyArray(10) as Long, then the compiler will actually create an array with 11 array entries instead of 10. The programmer can then access the array using all 11 entries, like using MyArray&(0) = 1234 or MyArray&(10) = 5678 without overwriting another variable's data space. When accessing arrays, array dimensions are not bounded, so if the programmer goes over the array's limit, like MyArray&(11) = 666; when the code executes, the next variable declared will be corrupted.

String arrays can be accessed in two ways. The first way is to make the compiler access them by treating the array as an actual string (eg: A string of characters). The second way (and the traditional BasiEgaXorz way) is to access strings like byte data (eg: on character at a time). The first method of accessing strings in BasiEgaXorz is almost like accessing normal strings in QBasic. For example:

		DIM Names(4,1) as String
Names$(0,0) = "Bob" Names$(1,0) = "Bill" Names$(2,0) = "Jane" Names$(3,0) = "Harry" FOR A = 0 to 3 PRINT Names$(A,0), NEXT

Strings can be accessed using the second method by including an extra dimension to the array. The extra dimension specifies which character, or byte you want to access. If the programmer accesses a string array using this method, then the data type is handled like an integer, or a long data type. For example:
		FOR A=0 to 3
			FOR Char = 0 to 8
				PRINT CHR$(Names$(A,0,Char));
				' Note the CHR$() in this line -> The character is
				' actually handled like an integer or long data type
			NEXT
		NEXT
				
Accessing strings by characters can be good for making levels, or when the programmer wants more speed than the MID$() instruction. When using * to set the size of the string, the compiler will ALWAYS add one more byte to the number to compensate for the null character, and will then make sure that the resulting size is always even (since we're using a 16-bit processor).

Argunerics
Arguneric is a word that I made up, and its one thing that google can't find =).
Argunerics are extensions to variable and functions. They extract individual bits out of them. The arguneric is placed right after the variable or function, seperated by a period.
For example, to extract bit 6 out of a variable, do the following:
MyVar=Whatever.6 ' Whatever is the variable name, and 6 is the bit number Also, you can specify what bit you want in another variable.
MyBit=6 ' Store the bit number in a variable
MyVar=Hello.MyBit ' Extract bit MyBit of Hello into MyVar
An expression is said to be TRUE when it contains any value other than 0. An expression is said to be FALSE when it contains the value of 0
Knowing this, argunerics can be used sequentially with the If command. For example, to detect for the START button:
If Joypad().7 Then Print "START IS PRESSED" Later on, argunerics will be expanded to other things other than bit numbers.

Immediate Operators
Increment Integer/Long
Description+Usage: Increases an integer/long number variable by 1. To use, just insert the variable name on the first line, and end it with a ++, like in C
Examples:
Foo++
Ogla[a+3]++
Frag&++

Decrement Integer/Long
Description+Usage: Decreases an integer/long number variable by 1. To use, just insert the variable name on the first line, and end it with a --, line in C
Examples:
Foo--
Ogla[a+3]--
Frag&--

User-Defined Functions and Subroutines
First, before going over functions and subroutines in BasiEgaXorz, we'll need to define some terminology. The purpose of functions and subroutines are to organize code easier, and to seperate the main variables from the local ones inside a specific region. Any region oustide functions and subroutines is called the main loop. The main loop is the starting point in your program, and can contain variables both local and global to functions and subroutines. Functions and subroutines are totally seperated from the main loop, which is why functions and subroutines give your program much more flexibility, and can keep your code better organized.

Variables are defined as global by using the GLOBAL command to declare a variable (and then use the same syntax as the DIM command). The concept of global and local variables is important because it will define which variables will be seperated from the main loop, and then other functions. Usually, very important variables are defined as global, as in you want other functions to access the same variable. There really is no way to say that having too many globabl variables is bad for your program. First, in BasiEgaXorz, the advantages of using global variables is that not that many parameters will need to be pushed onto the stack (making function calling very fast), the compiler won't need to declare more new local variables, and using globabl variables will consume less heap space compared to pushing new variables onto the heap. The disadvantages of using global variables is that your program will basically lack flexibility. Keep in mind that the Sega Genesis is an 8MHz processor with only 64kbytes of memory, so it's your call. Programs will suffer in performance if your program makes too many calls to functions. The compiler can also declare global variables automatically through compiler options. Local variables will then have to be defined by using the LOCAL statement. If automatic global variables are turned off, then any variables declared using DIM are automaticaly made local. The only variables that cannot be defined in the parameters list are arrays. Functions cannot return array values either.

Functions are declared using: Declare Function FunctionName(Parameter1 as Data Type, Parameter2 as Data Type, ...) as Data Type. The data type for parameters, and the returning value can either be Integer, or Long, or String. Parameter1 and Parameter2 can be any variable name the programmer wishes to store parameters, and then retrieve the values when the function is called. Functions and subroutines must be visible during Pass 1 of compilation. In order to be visible, there must be absolutely no space at the begining of Declare, or else the compiler is going to give you many errors! Use End Function to go back to coding in the main loop.

Functions are exitted by using the RETURN or EXIT FUNCTION commands. The returned value is also sent through the RETURN, or through EXIT FUNCTION, where the value to return is included in the last parameter of these commands. Finally, here is a small example of a function:
	num1& = 1234: num2& = 5678
	print "Original Values: ", num1&, num2&
	print "43656 + 657769 = "; Add&(43656, 657769)
	print "Anything Changed? ", num1&, num2&

Declare Function Add(num1 as Long, num2 as Long) as Long
	Return num1&+num2&
End Function
				
Subroutines are almost exactly the same as functions, but instead, cannot return values. Subroutines are declared using Decalre Sub SubName(Parameter1 as Data Type, Parameter2 as Data Type, ...). You can exit out of subroutines using Return or Exit Sub. Calling subroutines is easy, for example:
	Global time as Long
	time& = 1000
	AddTime 60
	Print time

Declare Sub AddTime(numtoadd as Long)
	time& = time& + numtoadd&
	Exit Sub
End Sub
				
Functions and subroutines can be recursized in BasiEgaXorz. The compiler will pre-record all the variables that are included in a subroutine, and then compare it with the variables outside the subroutine. Any variables in the main loop will be pushed onto the heap, so that your function can then use the variable space. When the functions exits, the original values from the variables in the main loop will be put back. This goes for the same in recursizing functions, when a function executes, old values from variables will be pushed onto the heap, and then will be popped back when it leaves. Be sure to not recursize too many functions, or allocate too many variables in the main loop, so that there's very little space for the heap and stack to work with. The more variables you use inside your functions, the more heap space you will need.

Sines/Cosines
Sine and cosine values are not generated during run-time, and they will never be. I know that this isn't 'Modern Day BASIC Protocol', and sines/cosines are essential to games now these days (circles, bouncy text, objects on a line, projectiles, whatever). But these is another method to generate sines and cosines. Go to -Pan- of Anthrox's- site and download Roller Coaster. It will generate the sine and cosine values for whatever waves you need, so you can just plug the values into your program with a Data statement and such. Doing this is a whole lot faster, and saves lots of memory compared to generating sines and cosines during run-time =).

Interrupters
Two interrupters are currently supported. There is the horizontal interrupt, and verticle interrupt.

Verticle Interrupter
The verticle blank stays active for 20 scan lines, which is about 1.27 ms. If you want your interrupt to finish before the screen starts to be redrawn, you gotta make your interrupt code small. Warning, when updating the screen inside the verticle interrupt, some commands might mess up the screen. For example, if the main execution loop is displaying a string, and then a verticle interrupt occurs and starts drawing another string, the string that is drawn during the verticle interrupt might insert its characters in before the command in the main loop finishes its drawing. The case is rare, the timings have to be just right. For some commands, all interrupts are disabled, and are re-enabled when they are done finishing execution. Most of these commands are display routines.

Horizontal Interrupter
The verticle blank stays active less than about 12 us (micro-seconds). No more than 12 assembly commands can be executed during this period (assuming each instruction is 1 us, which is the 'best case' execution time). There is a counter that counts down each time a horizontal blank occurs. When this counter drops to 0, a horizontal interrupt occurs. This counter can be pre-set using the HBALNK command.

Machine Code Language
There are so many low level things in the Sega that i can't simply catagorize under this BASIC document, including the stuff for BasiEgaXorz's low level routines itself. Any assembly language questions should be asked on the forums. Look down at contacts at the very end on the document. Also look at the Call command for simple stuff.

User Defined Assembly Language Subroutines and Functions
Assembly language subroutines and functions have the same format as regular user defined functions and subroutines that was introduced in v1.00 of the compiler. The only difference in assembly language functions, or subroutines is that the actual routine code is coded in assembly language, which is much faster than compiled basic code. With assembly language functions and subroutines, the programmer is able to define a function, or subroutine with a list of parameters, which will actually be the CPU registers (d0-d7 for data, or a0-a7 for a pointer). To get started, an assembly language function or subroutine can be defined as follows:

' For a subroutine
Declare Asm Sub SubroutineName(Parameter List)
End Sub

' For a function that has a return value
Declare Asm Function FunctionName(Parameter List)
	' Return the value of 123
	move.l	#123,d0
End Function
				
The paramter list specifies which values from the called function go into the CPU registers. The parameter list can accept the data registers, d0-d7, which will return the actual values of what the programmer passes to the sub or function. When specifying a data register, the size of the data register (byte, word, or long) has to be specified somewhere in the parameter list, along with the actual data register. For instance, to put a byte value into d0, you could use either the d0.b or d0 as byte (both will do the same thing). The same goes for word, and long data types. If an address register, a0-a7, is specified, the pointer that holds the value that is passed to the sub or function will be returned. The pointer will only return the value in the heap. It will not return the actual location of a variable. A size doesn't have to be specified for address registers, since a long, or 32-bit magnitude is always assumed. However, a data type has to be specified for an address register, so that the compiler will be able to distinguish whether it should return a pointer for an integer value, or a long value, or a string (all which have different offsets in the heap).

Acceptable parameters:
d0.l
d0 as long
d2.b
d3 as byte
d0.w
d5.w
d6 as word
a0 as integer
a1 as long
a2 as string
				
An example of a user-defined assembly function:
Declare Asm Function FunctionName(d0.b, d1.l, a0 as string, a1 as integer, a2 as long)
	add.b	#1,d0			; add 1 to the first parameter (byte)
	lsr.l	#4,d1			; Shift the second parameter right by 4 times (long)
	movem.l	d0/d1/a1/a2,-(a7)	; print_c might trash our values
	move.b	(a0)+,d0		; Print the first two characters in the third parameter (string)
	jsr	print_c
	move.b	(a0)+,d0
	jsr	print_c
	movem.l	(a7)+,d0/d1/a1/a2	; Restore the value of d0,d1,a1, and a2
	move.l	(a2),d3			; Retrieve the value of the fourth parameter and store it in d3 (long)
	ext.w	d0
	ext.l	d0
	add.l	d3,d0
	add.l	d1,d0			; Return d0+d1+d3
End Function
				
To call the above example in a program, a programmer might use something like this:
	MyVar& = FunctionName(123, 65536*65536-1, "Hello!", 45, &h12345678)
				
Tips: Remember, BasiEgaXorz uses the heap to pass values between calling the function, and executing the actual function. Therefore, when updating values that are pointed by address registers, the value only gets updated in the heap, which will be garbage collected after the function is finished being executed. To insert labels into your function, you need to use local labels. In SNASM assembler, you use local labels by tacking on a @ to the front of your label, eg: @MyLabel: bra.s @MyLabel.

Feel free to use address registers a0-a2 in your assembly language subroutine. Address registers a3-a7 are special registers that basic will use, which must not be modified by the function. A3 holds the address of the start of the stack. Modifying A3 won't mess up your program, but you will lose track of where the heap starts for your function. A4 holds the video port address for fast access. A5 holds the current position of the heap. Your function can use the heap as much as it wants, to hold values, or whatever. For example, you can use it like move.l #123,4(a5) or whatever. A6 holds the current position of the data pointer. A7 holds the stack position. Modifying A3 and A5 won't do any harm to your BASIC program.

Low-Level Video Setup
Default VRAM Map
Scroll B                   = $E000 - $FFFF [8192 Bytes]
Scroll A                   = $C000 - $DFFF [8192 Bytes]
Patterns (Tiles 1520-1535) = $BE00 - $BFFF [1856 Bytes]
Window                     = $B000 - $BDFF [2240 Bytes]
Patterns (Tiles 1396-1407) = $AE80 - $AFFF [384 Bytes]
Sprites                    = $AC00 - $AE7F [640 Bytes]
H Scroll                   = $A800 - $ABFF [1024 Bytes]
Patterns (Tiles 0-1343)    = $0000 - $A7FF [43008 Bytes]
					
Default VDP Register Setup are as follows:
move.w #$8006,($C00004) ; Mode #1
move.w #$8154,($C00004) ; Mode #2
move.w #$8B00,($C00004) ; Mode #3
move.w #$8C81,($C00004) ; Mode #4
move.w #$8700,($C00004) ; Background
move.w #$8800,($C00004) ; Low
move.w #$8900,($C00004) ; Low
move.w #$8230,($C00004) ; Scroll A Name Table
move.w #$832C,($C00004) ; Window
move.w #$8407,($C00004) ; Scroll B Name Table
move.w #$9011,($C00004) ; 64*64
move.w #$9100,($C00004) ; Window X
move.w #$9200,($C00004) ; Window Y
move.w #$8556,($C00004) ; Sprites Name Table
move.w #$8600,($C00004) ; Low
move.w #$8D2A,($C00004) ; H Scroll
move.w #$8E00,($C00004) ; Low

Programming for the 32X Extension
Note: All commands have to have a space/tab in front. Sega 32X specific commands can only be used on projects that are compiled as a 32X Rom. Only this can be enabled through the options dialog. There is no OPTION command inside BASIC to make the compiler compile for 32X.

This section describes the commands and methods that BasiEgaXorz uses to communicate with the 32X peripheral. This section does not give a very friendly overview on how the 32X extension actually works, or how the different video modes work. Places to read up more on the 32X are located at http://devster.monkeeh.com/sega/32xguide1.txt, which is my 32x guide. Another useful place for 32X documents is fonzie's website, which is located at Fonzie's Document Site. You will need to understand how the 32X video controller works, before you can actually use it in BasiEgaXorz using the frame buffer arrays.

Command_MARSSWAPBUFFER:
Syntax: MarsSwapBuffer
Description: Swaps the dual video buffers for the 32X display. The 32X extension utilizes a dual frame buffer type of controller for the display. One of the buffers will be dedicated to the display, and another buffer will be dedicated to drawing. The CPU has unlimited access to the buffer that is used for drawing, as in the CPU does not have to wait for the video controller to finish displaying, before the CPU can access the drawing buffer. Instead, the video controller will display the contents of the frame buffer that is being used as the display buffer. While the CPU is drawing to the drawing buffer, the user will not be able to see the changes made to the drawing buffer, until the frame buffers are swapped. When the buffers are swapped, the display buffer now becomes the drawing buffer, and the drawing buffer is now able to be seen on the TV. The command used to swap the frame buffers in BasiEgaXorz is MARSSWAPBUFFER.

The whole point of having dual frame buffers is to speed up access between the CPU and video memory, and to prevent drawing changes from being shown on the screen while the display is being displayed. The buffers need to be swapped when the programmer has finished updating the current gaming screen. This command also waits for VBLANK before swapping the buffers.
Back to the 32X Section

Command_MARSVIDMODE:
Syntax: MarsVidMode <Drawing Mode>, <TV Format>, <Priority Control>
Description: This command sets the different video modes of the display controller. The 32X has three different display modes: Packed Pixel Mode, Direct Pixel Mode, and RLE Mode. The first argument in this command specifies the mode: DM_BLANK (Display off), DM_PACKED (Packed Pixel Mode, or 8 bits-per-pixel DM_8BPP), DM_DIRECT (Direct Pixel Mode, or 15 bits-per-pixel DM_15BPP), and DM_RLE (RLE Mode).

The second argument specifies what type of TV will be hooked up to the 32X. This argument can either accept TV_NTSC (or TV_224 which does the same thing), or TV_PAL (or TV_240).

The third argument specifies whether the 32X will have display priority over the Genesis display. The two valid arguments for this command are: PRIO_GEN or PRIO_32X.
Back to the 32X Section

Command_MARSVIDREQUEST:
Syntax: MarsVidRequest
Description: This command forces the video controller to accept commands from the Genesis. If you're using the 32X with BasiEgaXorz, and are controlling the display through the MarsVram, or MarsVramOw, and MarsCram arrays, then you have to use this command before you can start using these variables. If the SH2 Processors need the video controller to display stuff, then this command shouldn't be used.
Back to the 32X Section

MarsVram Array
Description: Reading, or writing to this array will directly access the drawing buffer of VRAM. The array can be accessed as a string/byte (MarsVram$(location)), or as an integer/16-bit word (MarsVram(location) or MarsVram%(location)), or as a long/32-bit-word (MarsVram&(location)). The size of VRAM is 262,144 bytes long.
Back to the 32X Section

MarsVramOw Array
Description: This array direclty accesses the Overwrite portion of VRAM in the current drawing buffer. The array can be accessed as a string/byte (MarsVramOw$(location)), or as an integer/16-bit word (MarsVramOw(location) or MarsVramOw%(location)), or as a long/32-bit-word (MarsVramOw&(location)).
Back to the 32X Section

MarsCram Array
Description: This array direclty accesses the Color RAM for the display controller. The array can be only accessed as an integer, or a 16 bit data type (MarsCram(location) or MarsCram%(location)). The CRAM has 256 different color entries, which is used for 8bpp mode, or RLE mode.
Back to the 32X Section

Multi-Region Sega CD's
Okay, so you live in some 3rd world country, and you've made a Sega CD iso, and you want to play it on the real thing. BasiEgaXorz compiles iso's for use only in the USA, and won't work for some other country's Sega CD (or Mega CD) without some conversion. You can convert the iso image with MoD's ConvSCD to play your favorite BASIC game on your console. Homepage for it is here http://www.retrodev.com/convscd.html.

Downloads
PLEASE READ THE DISCLAIMER BEFORE DOWNLOADING!
History

1/3/2010
v1.37
- This release is mainly for supporting RAM game compilation, and the LAKABAJO uploading system
- Added VRAM Initialization data instructions DATA, DATAINT, DATALONG, DATAFILE
- Added the TILEORG istruction for VRAM Initialization
- Some more bug fixes and stability issues fixed
8/28/2008
v1.28
- Fixed many bugs in assembly that ASMX made
- Fixed the INPUT and GETS commands to not break the heap inside functions
- Declaring a variable with an absolute address inside a function gives a compiler error now
- No more mot2bin.exe
- Doing a=a*-1 is functional again
- Compiling the fake_variables.bex example works
- The assemble function works again
- Bugs fixed with user-defined subs/functions breaking the heap
- A bug is fixed, where putting spaces in between parenthesis now works
- Fixed a bug with the DATALONG command
- Fixed a bug when entering strings with the INPUT command
2/20/2008
v1.23
- BasiEgaXorz now uses the ASMX assembler!
- Not everything has been tested 100% with this version, so if something is broken, report the bug, and revert back to version 1.20!
2/11/2008
v1.20
- Fixed the READ, and READINT commands when using long variables.
- Added support for arrays in the commands READ, READINT, READLONG, GETS
- Fixed the GETS command to not declare integer or long variables that are very big
- Improved the INPUT command to be more BASIC like
- Added lower case letters to the INPUT command. Press the C button to switch between lower case letters and upper case
- Fixed a major bug with storing data with the DATA command.
- Fixed a bug with the Mid$ function, which was broke in v1.00 of the compiler
- Fixed a compiler bug when opening a souce file that is in a completely different drive
TODO -> Add the command DataStr
- When a file has successfully compiled, the ending dialog will now show the time that was spent assembling the source with the SNASM assembler
- Fixed the VarPtr&() Function to work with the newer array data types
- Fixed expressions having the form: str$(val(a)+val(b)), str$(val(a)<>val(b))
TODO -> Print 1*65536 is broken
- Fixed a major bug when declaring more than one sub or function
- Added an option to turn off the compilation summary at the end of compilation
12/25/2007
v1.00
- The compiler will no longer give an error when using the same labels in inline assembly
- Added the ability to transform data within code into variables, also called "Fake Variables"
- Fixed bugs with LoadTiles
- Fixed a bug with Datafile with even/odd addresses
- Fixed a bug when using &h0 as a constant
- Fixed a bug with EndCode&()
- Fixed a bug with using integer addresses inside the peek functions
- Replaced the buttons on the toolbar with an "imagebox", so mscomctl.ocx is no longer required
- Fixed a bug that would crash the program intermitently if the text window is maximized
- Added an option to change the font foreground and background colors
- User can now define a custom location for variables declared with Dim. See Dim xxx AT xxx
- Fixed SETSCROLLMODE and SETSCROLLPLANE to now work with lower case settings
- Fixed minor bugs with using strings inside DATA
- Added a feature to SLEEP and SLEEP2 to change between ending the sleep command at the begining of the blank, or at the begining of drawing the video
- Fixed a bug with the HV Counter and running on real hardware - The M3 bit in VDP register mode #0 was set, so the counter is latched when a trigger on HL is executed. On real hardware, triggers upon reset are common.
- Fixed major problems with the heap reallocating itself during interrupters
- Fixed more major problems with the displaying characters and using interrupters
- Fixed a bug with the interrupters. If your interrupter ran for too long, the interrupter would be called back again
- The external interrupter will now latch the HV counter upon enabling the external interrupter. When its disabled, it will turn latching off
- Individual string characters can now be accessed from String arrays
- 32X Support! Read the 32X special commands, and functions
- Fixed a bug when you put ENDIF and there's no preceeding IF, the compiler would crash and burn
- First version to use SyNtAx CoLoRiNg!
- Fixed a bug when doing PRINT 90+78*(3+4)
- A bug still exists, ie: PRINT 1+9999999999999 or PRINT 2+9999999999999, and cannot be fixed. However, doing PRINT 9999999999999+1 will work because the compiler will know in the begining that it will be dealing with long number data types!
- The compiler will no longer crash when there is an overflow in assigning large numbers, like long&=999999999999
- Fixed a bug with MEMCPY and printing text
- Fixed a bug with HBLANK always staying at 0
- Added the functions VBLANKON() and HBLANKON()
- Added the command WAITRASTER that will resume execution when the TV starts drawing on a specified line
- Fixed a bug with the compiler not finding snasm68k if the working directory was not in basiegaxorz
- Added a command VIDMODE to switch to either 40 cell mode (default) or 32 cell mode
- Added FontForeEntry and FontBackEntry to the list in the OPTIONS command
- Added OPTION Explicit to the option command, and can also be forced in the options menu
- Added the LOADFONT command
- Added more options to set the text drawing limits: TEXTHEIGHT, TEXTWIDTH and TEXTSTART options
- Forgot to halt the Z80 during CLS (clear screen uses video DMA)
- Custom functions and subs can now be declared
- Added OPTION CaseSense to the option command, and can also be forced in the options menu
- Added SELECT CASE
- Added DO and LOOP loops
- Automatic Indentation and expanding tabs into spaces options have been added
- Made a new style options window since I couldn't cram more stuff in the old one
- Added the command DRAWTILESINC2 that will draw tiles up->down, left->right
- Added a check to halt the cpu if a RETURN instruction is used without calling a subroutine
- The DIM statement can accept more than one variable in a list, eg: Dim a as long, b as integer, ..... Due to this, some things are broken. Can't do: Dim a as string, b as long, c as integer: Print "Hello!"
- Limited user defined SUB/FUNCTION support
- Added the command FONTPAL
- Fixed a bug with horizontal scrolling problems on real hardware
- Fixed a mistake in scrolling plane B verticle for both SCROLL and SCROLL2
- Added the function READSCROLL() that will read the value of the scroll memory
- Fixed a bug with using the INPUT command with 6 button joypads on real hardware
- Fixed a bug in PRINT and PUTS that ignored seperators , and ; in multi-line commands
- Interrupters no longer save the data pointer, so data commands can be used in interrupters
- When a compiler error occurs, the editor cursor is moved to the line containing the error and the line is highlighted
- Fixed a bug with STR$() while using other string in the same expression before STR$() is evaluated
- Fixed a major bug with ELSEIF not being recognized as ELSEIF. This bug is different from the ELSEIF nesting bug, which might be fixed soon
- Fixed more bugs with the interrupters and heap allocating. The heap is now offset to an even address so assembly code can use word or long values in the heap, eg: command INPUT
- Fixed bugs with instructions that require a long data type, and didn't accept any integer constants. Some of these commands were POKEINT, POKELONG, etc
- If there are no arguments in WAITPADUP then joypad 0 is assumed
- Finally fixed the ELSEIF nesting bug that has been ignored since v0.08
- The number of consecutive IF...THEN or ELSEIF...THEN has been increased from 20 to infinite
- Fixed the SHLINK command to work a little better. Before, the heap and stack were reset to the default, but now they're just changed depending on the condition of run-time
- SPRITEPOSX() and SPRITEPOSY() now truncate values over 512
- Added options to select different text priorities so text can now be overlayed on top of sprites
- Fixed Redo bug that would crash the program
- Fixed a bug with using comments (begining with ') after THEN keyword
- UNIX line feeds in source files supported
- Added the commands GLOBAL and LOCAL to assign scopes for variables used in user defined subs and functions
- Added command WRITEP and the function READP to read and write to variables located in an external 8-bit ram
- Fixed some stuff in 32x headers so that roms can now run on the Gens emulator
- Fixed a major bug with the Genesis requesting frame buffer access from the 32x (now roms can run on real hardware!)
- Fixed a minor GUI bug that occurs when the user quits the application with two documents opened, with one docuemtn that has been modified that has lost its focus. Clicking YES on the form that asks if you wish to save will make the form keep popping up infinitely
- Now you don't need to use [AND], [XOR], or [OR] to specify logical operations =D! Just use the operators without the brackets, just like in regular basic, eg: a=&h1234 and &h0ff0. The NOT operator isn't like this yet because there are problems with ordering. [AND], [OR], and [XOR] with the brackets will still work for compatibility with old sources
- Fixed a bug with function LEN() that can mess up the heap
- Added more arguments to the INK command that will draw text and tiles in other different ways. Also added the COLOR command, that will do the exact same thing as INK
- When booting programs, the video draw mode will be set appropriately to PAL or NTSC so programmers don't need to set this themselves
- Fixed a bug with SCROLL2 LEFT and SCROLL2 DOWN
- Fixed some more bugs with the INPUT command, once again
- Fixed a bug, again, with the PRINT command that misinterprets semi-colons. For example, this works now like it's suppose to: PRINT "hi": INK 1: print "YO"
- If the third argument in DRAWTILE (the argument that asks for a Y coordinate) is omited, then Y is 0. The X coordinate can range from 0 to 16383 for planes that are 128x128 large
- Fixed a buncha argument parsing bugs with some commands
- Added more Sega CD specific commands that deal with external data loading
- LOADSCD can now copy data from a CD to variables, or directly to VRAM
- Multi-dimensional array support has now been added, even though I said it was impossible!
- Improved the way string arrays are handled
- Changed commands SLEEP, SLEEP2, VALT, HALT, DALT, HBLANKON(), VBLANKON() to now act upon the HV counter, not the VDP status register
- Fixed a bug in the command TVSET
- Fixed a bug with hexidecimal numbers. Anything like &hFFFF won't turn into a negative number.
- String constants in DATA statements no longer need to be zero-terminated. The compiler is still backwards compatible with strings that were zero-terminated by the programmer.
- There can now be ten files in the recently opened list instead of just one
- Right click on the source editor now works again
- Fixed some bugs that prevented Sega CD ISOs from playing on real hardware
6/23/2004
v0.19
- Added the ability to create faster subs and functions using just plain assembly. The compiler will not place any slow, bloated code for ASM SUBS or ASM FUNCTIONS.
- Added the endcode data label
- Fixed a bug when using argunerics directly on a function, where the future expressions would not be interpreted. Eg: a=joypad().7+1, the +1 would be missed.
- Finally, other basic programs can be included into other basic programs using the INCLUDE command. There's a catch though, included can only be nested once, the begining line label check doed not work, you cannot add multiple statements on the INCLUDE command, and it is still very buggy and will be buggy for a long time. Including programs was a hard to do with the compiler since everything is compiled linearly.
- More IDE junk: In the options dialog, an emulator and tile editor can be searched for with an open dialog box
- Added an Open Recent menu
- Included a window that will display all Sega CD programs added with the ADDSCD command for Sega CD Boot ISOs. It shows the filename, and its assigned sector. This will be helpful for keeping track of sector numbers. - Added the support for in-line constants with the # symbol
- Improvements were made to assiging labels to data (data labels)
- Fixed yet another bug with DRAWTILES with the Tiles VRAM Offset argument, where it actually didn't work
- Added a new command, DRAWTILESINC which doesn't use any data labels, but draws tiles in an incrament fasion, eg: specify it to start at tile 128, and it will draw all tiles from 128 to etc
- Added a new commnad, DRAWTILESOVR which acts like DRAWTILES, but tiles marked 0 will not be drawn, preserving the background
- Fixed the clr.l d1 bug with the command DRAWTILES and DRAWTILE
- Added the functions POSX, POSY, CURINK to determine the cursor's position, and the current ink color
- Added the function READTILE
- The compiler adds a label to each ASM nested statements, and to libraries so the user can use @label and any label name for labels
- All 4 PSG channels are set to mute in the start up
- Fixed the Soft Reset bug on real hardware. The software would always check the status of the HV counter on startup, and would infinitely loop if it wasn't in a specific range - pretty nifty =D
- Some GUI optimizations here and there
- Fixed a bug when the last open document was closed, some buttons would dissapear, and some buttons would crash the program
- Splash screen (actually the about screen) added, and is shown when a new compiler version is executed for the first time
- When multiple documents are in the command line, the IDE will open them all in multiple windows
- The External TH Interrupter on the joypad port is now supported
- The command LoadTiles is now 3 times faster! Note: Speed is measured only when the screen is disabled. With the old routine, it would take 1.08 minutes to load 1024 sets of 1024 tiles (Equals 32mb). With the new routine, it took 0.37 minutes.
- The functions HFlipTile, VFlipTile, RotateTile, Priority, and Palette have been added to customize drawing tiles
- Some Editing Enhancements: Find, Find Next, Search and Replace, Insert Date+Time, and Go To Line
- Fixed a bug with the Dim command that allocated 2 bytes to long variables
- Fixed a bug with ReadLong that allocated 2 bytes to long variables that haven't been created
- Added the commands FastTileCopy and MemCopy to do some low-level, high-speed memory copying
- <, >, <=, >=, and <> string comparisons works now. When a string is compared to another string, the destination value will be an integer.
- The function UnitType added to determine whether the machine is a domestic, or overseas unit
- The function TVType added to determine whether the machine is NTSC, or PAL
- The function VDPRAMRead() and the command VDPRAMWrite were added to read/write directly to the VDP RAM
- The functions Read$, Read, ReadINT(), and ReadLONG&() were created, so execution time is faster if data doesn't need to be read into a variable, but passed into an expression
- ReOrgCode option added to change the code address for Sega CD Porgrams
- ReOrgVars option added to change the next variables address to tack on more RAM storage for Sega CD games
- StartCode& function added to give the first byte of compiled code
- EndCode& function added to give the last byte of compiled code
- External RAM Support for variables
- .BEX file associations can now be done within the IDE
- The expression system now handles parenthesis, eg: a=4+((((7*2)*(1+2))*(2*2))+5) works
- Assembly code is automatically optimized
- The command FAKE has been added to virtually make variables into fake data labels for use with RELOAD, READ, WRITE, and tile/palette loading commands
- Genesis roms can now be compiled for PAL machines with the command TVSET
- Regmove.x can now use immediate values for sourcing arguments
- Fixed a bug with LOADTILES. Now it clears register d1 before use.
- Fixed a bug in the INPUT command when the screen scrolls down
- Added font and tab options to the IDE
- BasiEgaXorz low level routine speedups: Faster displaying of strings in PRINT,
4/21/2004
v0.12
- Fixed a bug in the expression handling when you do if c then
- Fixed a bug in the bit argunerics
- Added a new command Sleep2 which delays on each horizontal blank instead of verticle blanks
- Added a new function: LBLPtr&() which gets the address of a data label
- Label in the Palettes command can now have an offset
- Label in the DrawTiles command can now have an offset
- INPUT and GETS commands can now handle integer and long data types
- Fixed a bug when a cpu exception occurs, or when a breakpoint is reached
- Finally added long (4 byte) multiplication, division, and modulo
- Added the instruction RegMove.l, RegMove.w, RegMove.b to get assembly registers into variable, or vice versa
- Fixed a bug where if For, If, Dim, or Let were Uppercase, the compiler wouldn't identify it
- Added an option to run the the Compiled ROM/ISO in an emulator after it is compiled
- Changed the documentation: switched the Height and Width arguments around for the AddSprite function
- Added the Not() and Not&() Functions
- Can now open files from the command line, and the program can have more than one instance now
- Minimize bug fixed
- Fixed a bug in the Randmize command
- If While 1 is used, then the compiler will jump directly back the commands after the While command when a Wend command is encounterd. This makes While 1 loops very fast without having to solve expressions, or jump on a condition, etc
- Added the Exit While and Exit For commands
- Added the Continue While and Continue For commands
- Added the string functions: ChrW$ and ChrL$
- Added the functions: Asc and AscW and AscL&
4/11/2004
v0.11
- Now added the Let command
- When the Open/Save dialog is opened for the first time, its default directory will be the compiler's directory
- The Library command can now handle long file names
- Added the command: Incasm, which is like the Library command, except it doesn't search the "slibrary" directory for the assembler file. It either searches the project's own directory, or the compiler's directory if the source code is untitled
- Forgot to add the Ignore SCD Commands option. It is now added
- Fixed a bug with the Sega CD commands that froze the main CPU
- Fixed the LoadSCD command to disable interrupters when loading a cluster
- Fixed the text DMA commands (CLS, Line Feeds) to work for the different planes
- Fixed the clear length in CLS
- Big sprite commands added
- Fixed DataFile to recognize labels not on the same line
- Now aligns DataFile to EVEN bounds
- For the 4th time, the FOR...next loop has been recoded, now even faster
- Compiler speed increase =D - by 200 times. The compiler doesn't use VB's buffers to store the compiled assembly file no more =). This bypasses all of VB's overhead, and makes it compile 100,000 number of lines of print "hi" in 48 seconds on a 1.2 ghz computer running number line checks.
- For the VB users, i created an option to save BASIC files with a .bex extension
- Fixed a bug where if you go print "wassup":a=a+1, it messes up
- Added a feature to the ASM command, where if you leave the second argument blank, the lines after ASM are the assembly source, and it end when it encounters an END ASM command.
- Added the Gets command, and changed the Input command around to act like the real basic Input command
4/5/2004
v0.10
- Added a color converter for color codes
- Data labels don't need to be on the same line as the data statement now. the compiler takes the last label encountered, and makes that the data label
- No more make.bat or make.pif files =D!
- No more rich text box :D!!! lots+lots of features with the ide were added/fixed because of this =P (too many to list here)
- Added more options for naming, and directories
- Sega CD audio playback commands added
- Datafile command now searches the project directory for the data file. If a project is untitled, the command will search the path of the compiler for the file. File names can no be longer than 8 characters (long file names)
- Drawing to different scroll planes, and to the window is now implemented for both text and graphics
- Added commands to format the window
- Updated the scroll command to do more things that take scrolling to the Genny's hardware capabilities
- Multiple Sega CD programs can be stored on one boot iso now
- Text+Graphics commands updated to change displaying properties
- Added a Puts command which displays text a whole lot faster, but more parameters are required for this
- Freed up 256 bytes of RAM
- List of New Commands: BGColor, FreeAllSprites, SetTextPlane, SetGfxPlane, WindowProp, Disable Window, Puts, Scroll2, SetScrollMode, SetScrollPlane, Write, WriteInt, WriteLong, AddSCD, LoadSCD, CDPlay, CDPlay2, CDStop
- More options for the option command: Option SegaCD, Option SegaCD Program, Option Cartridge - which overwrites the setting in the option menu to change the output file type
3/2/2004
v0.09
- Mostly fixes to the Master Routines:
- Fixed waitpadup. sometimes it messed up w/o detecting any key
- Fixed readint statement. putting in a variable causes an error
- Fixed drawtile. the x and y arguments were backwards
- Fixed chr$() function. the function never added a null to the heap
- Fixed data commands. the data command alligned all data to even bounds at the end of the data. if two data statements were one after the other, invalid data would appear if the first data statement was odd. this has been fixed by adding even allignments to the begining of all dataint and datalong commands, instead of data.
- Fixed data commands to accept &h as a hex number
- Fixed the immediate addition/subtraction operators to properly add long veriables. Before, it use to add 65536
- Redid the sprite system. Before, sprites were added by using the linking method of the Sega's hardware. Now, the routines don't even use linking, just straight 0-79. There were lots of bugs with the linking system.
- Sprites can now all be wiped out with a command
- When an interrupt occurs, 2048 bytes are added to the heap, which is gonna fix some interrupter bugs conflicting with surprise memory overwrites. Not very useful to know for beginers, but I thought I'd put it here for completeness =D
- Fixed traps and breakpoints to enable the screen if it was disabled
2/29/2004
v0.08
- Tab spaces are recognized as regular spaces
- Added a memory map viewer for variables in the gui for debugging
- Compilation of Sega CD isos supported (currently only 128k games)
- Compilation supported for Mask of Destiney's Transfer Suite
- Many many many fixes and optimizations to the expression engine and argument parser
- Added I/O functions poke and peek and their long/word subcommands
- Added a button on the toolbar to easily call the tile editor (custom sgtd.exe for basiegaxorz tiler will be released later)
- Added options for editor colors
- Interrupter handlers improved
- Performance improvements for the For...Next loop
- Added support for long 32 bit variables
- Random function finally added
- The horizontal blank interrupter is now supported
- Bug fixes to the shlink command - but still, just use sparingly, especially for testing games on the real system
- Cursor postion thing fixed in the gui
- DMA functions fixed from beta 0.05
- Made a much better joypad function. 6-button controller supported
- Hex$(), Chr$(), Bin$(), Mid$(), String$(), Left$(), Right$(), and Len functions added for string parsing
- Bit argunerics added
- Option command added for replacing the title header, and also to define Sega CD dedicated games, and default string size
- ShiftSprite added to relatively move the sprite without keeping track of its position
- Background plane scrolling added
- The ":" technique added (eg. the ":" in ink 3: print "wassup")
- Arithmetic shift added
- Negative number support for decimal numbers
- Support for hexidecimal arguments eg. &h1234
- And, Or, Xor operators added
- ElseIf finally added
- Sprite positions can be read with function SpritePosX or SpritePosY
- Single dimentsion arrays added only for Integer and Long data types
- 16 bit and 32 bit wide data supported with DataInt and DataLong, and for reading, ReadInt and ReadLong
- RGB function added
- Addsprite command is now a function
- Brighten and Darken commands added for fading in or out palettes
- Increment and Decrement operations added
- Added sound commands for the PSG for making sound effects (Sound, SoundVol)
- User defined assembly routines support added for the more advanced programmers
- VarPrt& function added
- Display can now be turned on/off for faster tile data loading using the Disable/Enable commands
- Halt, Valt, and Dalt commands added to wait for the horizontal/verticle blank before anything else is executed
- TVScanX() and TVScanY() functions added to read the HV Counter
- Palettes command added for adding multiple colors
- Input command added to easily get user input
- Str$ and Val functions implemented
- Assembly headers are built into the exe again
- Whenever an unexpected error occurs when assembling, an error log is created and displayed for debugging
- Fixed BasiEgaXorz to run on Windows 95 with a 486 running at 66 mhz =D
- Added a Trap command to act as a breakpoint for debugging
- Added error messages for CPU errors (eg. address error/illegal instruction/divide by zero) - these errors can not be recovered in run-time
- Rem and ' Comments supported
- Added a button to assemble a plain assembly file to binary
- A last quickie WaitPadUp Command added
- Fixed a string-function bug (eg. doing a$="asdf"+chr$(12))
- Fixed a bug with using an apostrophe in a string constant (eg: "what's up doc")
- Fixed a bug that messed up carriage returns in the editor

- A total of ~50 additions/fixes/changes :-)!!!
1/12/2004
v0.05 beta
- This update is for more commands, no optimizations/fixes have been done yet
- Graphics commands are now implemented
- Verticle blank interrupter implemented
- Colors commands and stuff added
- DMA functions are broke, use version 0.04
1/9/2004
v0.04
- Argument routine is redone (means that lots of things can be done now)
- Statements seperated by a colon now works
- More statements added: Data, Datafile, Read, Reload, While...Wend, End (Getting ready for graphics and sprites and tiles now and interrupts)
- There is now an option to disable the begining label check, and the proceeding label checks. If you're not keeping track of your labels, and you have this on, your program may refuse to compile. This option is for compiling larger programs quickly. If you have a program > 2000 lines, it'd be good to turn this on. If not, you don't need the option on.
- Comments added
- More tiny stupid bugs fixed
- Compiler optimized heavily
- Added a nicer font and changed to a better color =)
1/6/2004
v0.02
- Added Support for Functions to the expression routine
- Two character operators added (>=, <=, <>)
- Fixed stupid bug with pasting and saving
- Better shell() routine
- Compile time is faster (Can compile 3000 lines of "print 1+2-3" in 209 secs)
- Can compare strings now (Only = can be used for now)
- basichdr.s is not built into the compiler. The header can be modified if you want to add your own font for now, or change the colors, etc.
12/25/2003
v0.01
- Released first public release, version 0.01. Lots of things are unsupported, for I need to spend more time on the compiler (only took 4 days from now =D) and was released early for Christmas.

Bugs
The whole program is a bug. Report bugs at the forum or something, or email me, and i'll try to fulfil your request =). Look down at contacts.

KNOWN QUIRKS:
- In the IDE, a TAB is recognized as one character, so the column count is messed up with tabs
- Code with the following style won't work: Print 1+65536 or Print 1*70000 or print 1*r&. To fix this, you would have to do the following to make the compiler recognize the expression as a long data type: Print 70000*1.
Contacts
Need extra help? Go post in the forums, 99.9% of the time I myself will answer any question
Forums: http://devster.proboards22.com/ - You do not need to register to post in the BasiEgaXorz Support Forum if you don't want to. Just post as a guest.
Website: DevSter Speicialties
My Email (i don't read my e-mail =P, it'd be better to PM me something on the forums): jonorm123@hotmail.com

Credits
Driector, Manager, Programmer, Graphics Designer, More Programming Stuff, Everything else - Me
The dude that made Snasm68k - you rock man
Mask of Destiney - Props go to him for the Sega CD tech stuff
Tomman - First one to report bugs =)

DISCLAIMER
BasiEgaXorz is Copyright 2003-2008 by Joseph Norman. This software is provided as freeware. This software is provided as-is, and you may not distribute it to the masses (ex: on your web site), sell this software, or modify it without my written consent. I do not take any responsibility for things you mess up. READ the disclaimer below for the 200 word version of this.

YOU SHOULD CAREFULLY READ THE FOLLOWING USER AGREEMENT AND DISCLAIMER OF WARRANTIES AND LIABILITIES ("AGREEMENT AND DISCLAIMER") BEFORE DOWNLOADING BASIEGAXORZ. DOWNLOADING OR USING THIS SOFTWARE INDICATES YOUR ACCEPTANCE OF THIS AGREEMENT AND DISCLAIMER. IF YOU DO NOT AGREE WITH THIS AGREEMENT AND DISCLAIMER, YOU MAY NOT DOWNLOAD THIS SOFTWARE, AND YOU MUST IMMEDIATELY DELETE ALL COPIES OF THE SOFTWARE IN YOUR POSSESSION.

User Agreement: You may not rent, lease, or assign this software. You may not decompile, disassemble, or modify this software. You may not transfer, distribute or bulk-distribute this product without Dester's express written permission. You assume responsibility for the use of this software to achieve your intended results, and for the installation, use, and results of using this software.

Disclaimer of Warranty and Liability: DevSter does not warrant that this software will download correctly or that it will install correctly on your machine. DevSter does not warrant that the functions contained in the software will meet your requirements or that the operation of the software will be uninterrupted or error-free or that any software defects will be corrected. This product is provided solely on an "as-is" basis, and nor DevSter make any claim as to fitness for a particular purpose whatsoever. To the maximum extent permitted by law, DevSter disclaims all warranties, expressed or implied, including but not limited to, implied warranties of merchantability or fitness for a particular purpose.

DevSter has no liabilities for consequential damages. In no event shall DevSter be liable for any damages whatsoever (including, but not limited to, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of, or out of the inability to use, this product, even if DevSter has been advised of the possibility of such damages. DevSter reserves the right to modify or update any part of this Agreement and Disclaimer without prior notification.



BasiEgaXorz Copyright Joseph Norman, 2003-2010
Sega Genesis is Copyrighted by Sega