author: bocianu bocianu@gmail.com
Set of procedures to cover API functionality provided by:
https://www.olimex.com/Products/Retro-Computers/Neo6502/open-source-hardware
https://www.neo6502.com/
API documentation can be found here:
https://github.com/paulscottrobson/neo6502-firmware/wiki
It's work in progress, so please report any bugs you will find.
name: | value: | description: |
---|---|---|
N6502MSG_ADDRESS | $ff00 | |
NEO_GFX_RAM | $ffff | |
OPEN_MODE_RO | 0 | opens the file for read-only access; |
OPEN_MODE_WO | 1 | opens the file for write-only access; |
OPEN_MODE_RW | 2 | opens the file for read-write access; |
OPEN_MODE_NEW | 3 | creates the file if it doesn’t already exist, truncates it if it does, and opens the file for read-write access. |
FI_ATTR_DIRECTORY | 1 | mask for directory attribute |
FI_ATTR_SYSTEM | 2 | mask for system attribute |
FI_ATTR_ARCHIVE | 4 | mask for archive attribute |
FI_ATTR_READONLY | 8 | mask for read only attribute |
FI_ATTR_HIDDEN | 16 | mask for hidden attribute |
MEM_6502 | 0 | 6502 ram offset |
MEM_VRAM | $800000 | Video ram offset for blitter addresing |
MEM_GFX | $900000 | Graphics ram (tiles/sprites) offset for blitter addresing |
BLTACT_COPY | 0 | Blitter action: copy |
BLTACT_MASK | 1 | Blitter action: copycopy, but only where src is not the transparent value. |
BLTACT_SOLID | 2 | Blitter action: set target to constant solid value, but only where src is not the transparent value. |
BLTFORM_BYTE | 0 | Blitter data format: bytes. Supported for both source and target. |
BLTFORM_PAIRS | 1 | Blitter data format: pairs of 4-bit values (nibbles). Source only. |
BLTFORM_1BPP | 2 | Blitter data format: 8 single-bit values. Source only. |
BLTFORM_UPPER4 | 3 | Blitter data format: high nibble. Target only. |
BLTFORM_LOWER4 | 4 | Blitter data format: low nibble. Target only. |
name: | type: | description: |
---|---|---|
TN6502Message | record
end; | Structure used to prepare API message |
TSound | record
end; | Structure used to store note parameters |
name: | address: | type: | description: |
---|---|---|---|
NeoMessage | N6502MSG_ADDRESS | TN6502Message | structure used to communicate with neo6502 API |
wordParams | N6502MSG_ADDRESS+4 | array[0..3] of word | helping structure to easliy obrain or set word parametrs |
dwordParams | N6502MSG_ADDRESS+4 | array[0..1] of cardinal | helping structure to easliy obrain or set cardinal parametrs |
name: | description: |
---|---|
NeoSendMessage | function NeoSendMessage(group,func:byte):byte;Sends structure stored in NeoMessage, to Neo6502 API
parameters:returns: |
NeoWaitMessage;inline;assembler | procedure NeoWaitMessage;inline;assembler;Waits until Message from API is returned. |
NeoSubReset | procedure NeoSubReset;Resets the messaging system and its components. Should not normally be used. |
NeoGetVblanks | function NeoGetVblanks:cardinal;Return the number of vblanks since power on. This isupdated at the start of the vblank period.
returns: |
NeoWaitForVblank | procedure NeoWaitForVblank;Wait for new vblank. |
NeoGetTimer | function NeoGetTimer:cardinal;Get the value of the 100Hz system timer.
returns: |
NeoExecuteBasic | procedure NeoExecuteBasic;Execute BASIC |
NeoCredits | procedure NeoCredits;Prints the list of people involved, stored in Flash to save memory. |
NeoCheckSerial | function NeoCheckSerial:byte;Check the serial port to see if there is a data transmission. This is done automatically in Key Read.
returns: |
NeoSetLocale | procedure NeoSetLocale(lang:string[2]);Sets the specified locale code (EN.FR,GE...)
parameters: |
NeoReset | procedure NeoReset;System Reset. This is a full hardware reset. It resets the RP2040 using the Watchdog timer, and this also resets the 65C02. |
NeoMOS | procedure NeoMOS(cmd:pointer);Do a MOS command (a '* command') these are specified in the Wiki as they will be steadily expanded.
parameters: |
NeoWriteDebug | procedure NeoWriteDebug(c:byte);Writes a single character to the debug port (the UART on the Pico, or stderr on the emulator). This allows maximum flexibility.
parameters: |
NeoIsKeyPressed | function NeoIsKeyPressed(key:byte):byte;Return the state of keyboard key
parameters:returns: |
NeoSetChar | procedure NeoSetChar(c:byte;data:pointer);Use bits 0..5 of data bytes to define a selected font character
parameters: |
NeoDefineHotkey | procedure NeoDefineHotkey(keynum:byte;txt:pointer);Define the function key F1..F10 ($01..$0A) specified as keynum to emit the length-prefixed string stored at the memory location specified in txt. F11 and F12 cannot currently be defined.
parameters: |
NeoShowHotkeys | procedure NeoShowHotkeys;Displays the current settings of the function keys |
NeoGetScreenSize | procedure NeoGetScreenSize(var height:byte;var width:byte);Returns the console size in characters.
parameters:returns: |
NeoSetTextColor | procedure NeoSetTextColor(foreground,background:byte);Returns the console size in characters.
parameters: |
NeoGetCursorPos | procedure NeoGetCursorPos(var x:byte;var y:byte);Returns cursor position
parameters: |
NeoClearRegion | procedure NeoClearRegion(x0,y0,x1,y1:byte);Erase all characters within the specified rectangular region.
parameters: |
NeoCursorInverse | procedure NeoCursorInverse;Toggles the cursor colour between normal and inverse (swaps FG and BG colors). |
NeoShowDir | procedure NeoShowDir;Displays the storage directory. |
NeoLoad | function NeoLoad(name:TString;dest:word):boolean;Loads a named file from storage to selected address. If the address is $FFFF the file is loaded into the graphic memory area used for sprites, tiles, images.
parameters:returns: |
NeoSave | function NeoSave(name:TString;dest,len:word):boolean;Saves chunk of memory from defined address to a named file on storage.
parameters:returns: |
NeoOpenFile | function NeoOpenFile(channel:byte;name:pointer;openmode:byte):boolean;Opens a file into a specific channel. Modes 0 to 2 will fail if the file does not already exist. If the channel is already open, the call fails. Opening the same file more than once on different channels has undefined behaviour and is not recommended.
parameters:returns: |
NeoCloseFile | function NeoCloseFile(channel:byte):boolean;Closes a particular channel.
parameters:returns: |
NeoSeekPos | function NeoSeekPos(channel:byte;pos:cardinal):boolean;Seeks the file opened on a particular channel to a location. You can seek beyond the end of a file to extend the file. Whether the file size changes when the seek happens or when you perform the write is undefined.
parameters:returns: |
NeoTellPos | function NeoTellPos(channel:byte):cardinal;Returns the current seek location for the file opened on a particular channel.
parameters:returns: |
NeoReadFile | function NeoReadFile(channel:byte;addr:word;len:word):word;Reads data from an opened file. Data is read from the current seek position, which is advanced after the read.
parameters:returns: |
NeoWriteFile | function NeoWriteFile(channel:byte;addr:word;len:word):word;Writes data to an opened file. Data is written to the current seek position, which is advanced after the write.
parameters:returns: |
NeoGetFileSize | function NeoGetFileSize(channel:byte):cardinal;Returns the current size of an opened file This call should be used on open files and takes into account any buffered data which has not yet been written to disk. As a result it may return a different size to the NeoStatFile described below.
parameters:returns: |
NeoSetFileSize | function NeoSetFileSize(channel:byte;size:cardinal):boolean;Extends or truncates an opened file to a particular size.
parameters:returns: |
NeoRenameFile | function NeoRenameFile(fin,fout:pointer):boolean;Renames a file.
parameters:returns: |
NeoDeleteFile | function NeoDeleteFile(fin:pointer):boolean;Deletes a file or directory.
parameters:returns: |
NeoCreateDirectory | function NeoCreateDirectory(fin:pointer):boolean;Creates a new directory.
parameters:returns: |
NeoChangeDirectory | function NeoChangeDirectory(fin:pointer):boolean;Changes the current working directory.
parameters:returns: |
NeoStatFile | function NeoStatFile(fin:pointer;var size:cardinal;var attr:byte):boolean;Retrieves information about a file by name and returns it by referenced variables. If the file is open for writing, this may not return the correct size due to buffered data not having been flushed to disk. File attributes are a bitfield as follows: 0 - directory 1 - system 2 - archive 3 - read only 4 - hidden
parameters:returns: |
NeoOpenDirectory | function NeoOpenDirectory(fin:pointer):boolean;Opens a directory for enumeration. Only one directory at a time may be opened. If a directory is already open when this call is made, it is automatically closed; however, an open directory may make it impossible to delete the directory, so closing the directory after use is good practice.
parameters:returns: |
NeoReadDirectory | function NeoReadDirectory(var fname:string;var size:cardinal;var attr:byte):boolean;Reads an item from the currently open directory. This call fails if there are no more items to read.
parameters:returns: |
NeoCloseDirectory | function NeoCloseDirectory:boolean;Closes any directory opened by Open Directory.
returns: |
NeoCopyFile | function NeoCopyFile(fin,fout:pointer):boolean;Copies a file.
parameters:returns: |
NeoSetAttr | function NeoSetAttr(fin:pointer;var attr:byte):boolean;Sets file/directory attributes. File attributes are a bitfield as follows: 0 - directory (cannot be changed) 1 - system 2 - archive 3 - read only 4 - hidden
parameters:returns: |
NeoSearchDir | procedure NeoSearchDir(var searchstring:string);Prints a filtered file listing of the current directory to the console. On input:
parameters: |
NeoDoMath | function NeoDoMath(func:byte):byte;Performs API request to math coprocessing library. Not well documented yet.
parameters: |
NeoSetDefaults | procedure NeoSetDefaults(acol,xcol,solid,size,flip:byte);Sets colour for upcoming drawing operations.
parameters: |
NeoDrawLine | procedure NeoDrawLine(x0,y0,x1,y1:word);Draws a line.
parameters: |
NeoDrawRect | procedure NeoDrawRect(x0,y0,x1,y1:word);Draws a rectangle.
parameters: |
NeoDrawEllipse | procedure NeoDrawEllipse(x0,y0,x1,y1:word);Draws ellipse.
parameters: |
NeoDrawPixel | procedure NeoDrawPixel(x0,y0:word);Draws single pixel.
parameters: |
NeoWritePixel | procedure NeoWritePixel(x0,y0:word;c:byte);Draws single pixel.
parameters: |
NeoDrawString | procedure NeoDrawString(x0,y0:word;var s:string);Prints e string at the specified location.
parameters: |
NeoDrawImage | procedure NeoDrawImage(x0,y0:word;id:byte);Puts an image from the graphic memory to desired location.
parameters: |
NeoDrawTileMap | procedure NeoDrawTileMap(x0,y0,x1,y1:word);Draws current tilemap on desired area.
parameters: |
NeoSetPalette | procedure NeoSetPalette(col,r,g,b:byte);Changes color in system pallette.
parameters: |
NeoGetPalette | procedure NeoGetPalette(col:byte;var r:byte;var g:byte;var b:byte);Returns selected color rgb components from system pallette.
parameters: |
NeoGetPixel | function NeoGetPixel(x,y:word):byte;Reads pixel. Sets error if out of range.
parameters:returns: |
NeoResetPalette | procedure NeoResetPalette;Resets system palette to default. |
NeoSelectTileMap | procedure NeoSelectTileMap(mem,xoffset,yoffset:word);Sets the current tilemap.
parameters: |
NeoGetSpritePixel | function NeoGetSpritePixel(x,y:word):byte;Reads pixel from sprite layer. (0-15, 0 = transparency) Sets error if out of range.
parameters:returns: |
NeoSetColor | procedure NeoSetColor(col:byte);Sets colour for upcoming drawing operations.
parameters: |
NeoSetSolidFlag | procedure NeoSetSolidFlag(flag:byte);Sets the solid flag, which indicates either solid fill (for shapes) or solid background (for images and fonts)
parameters: |
NeoSetDrawSize | procedure NeoSetDrawSize(size:byte);Sets the drawing scale for images and fonts
parameters: |
NeoSetFlip | procedure NeoSetFlip(flip:byte);Sets the flip bits for drawing images. Bit 0 set causes a horizontal flip, bit 1 set causes a vertical flip.
parameters: |
NeoResetSprites | procedure NeoResetSprites;Resets the sprite system. |
NeoUpdateSprite | procedure NeoUpdateSprite(s0:byte;x,y:word;image,flip,anchor:byte);Updates selected sprite. To not update a value set its byte values to $80 (or $8080 for a coordinate). The coordinates cannot be set independently. Sprite 0 is the turtle sprite.
parameters: |
NeoHideSprite | procedure NeoHideSprite(s0:byte);Hide the sprite.
parameters: |
NeoInRange | function NeoInRange(s0,s1,range:byte):byte;Returns not zero value if the distance between the centres of the sprites is less or equal range value.
parameters:returns: |
NeoGetSpriteXY | procedure NeoGetSpriteXY(s0:byte; var x:word;var y:word);Returns coordinates of the selected sprite. Coordinates are returned in referenced variabled.
parameters:returns: |
NeoGetJoy | function NeoGetJoy:byte;overload;Returns base controller status. Bits are (from zero) Left, Right, Up, Down, A, B. Active state is 1.
returns: |
NeoGetJoyCount | function NeoGetJoyCount:byte;returns the number of game controllers plugged in to the USB This does not include the keyboard based controller, only physical controller hardware.
returns: |
NeoGetJoy | function NeoGetJoy(player:byte):byte;overload;Returns specific controller status. Controller 0 is the keyboard controller, Controllers 1 upwards are those physical USB devices. This returns a 32 bit value in Params[0..3] which currently is compatible with function 1, but allows for expansion. Bits are (from zero) Left, Right, Up, Down, A, B. Active state is 1.
parameters:returns: |
NeoMute;overload | procedure NeoMute;overload;Resets the sound system. |
NeoMute | procedure NeoMute(channel:byte);overload;Resets selected sound channel.
parameters: |
NeoBeep | procedure NeoBeep;Plays the startup beep. |
NeoQueueNote | procedure NeoQueueNote(channel:byte;freq,len,slide:word;stype:byte);Queues a sound to be played.
parameters: |
NeoQueueNoteX | procedure NeoQueueNoteX(channel:byte;freq,len,slide:word;wave:byte;vol:byte);Queues a sound to be played.
parameters: |
NeoGetChannels | function NeoGetChannels:byte;Returns the number of available sound channels
returns: |
NeoSoundFx | procedure NeoSoundFx(channel,num:byte);Play sound effect immediately clearing queue.
parameters: |
NeoGetQueueLen | function NeoGetQueueLen(channel:byte):byte;Return the number of notes outstanding on channel before silence, including any current playing note.
parameters:returns: |
TurtleInit | procedure TurtleInit(s0:byte);Initialise the turtle graphics sytem using selected sprite, don’t show it.
parameters: |
TurtleRight | procedure TurtleRight(deg:word);Turn the turtle right by selected number of degrees. Show if hidden.
parameters: |
TurtleMove | procedure TurtleMove(dist:word;col:byte;drawing:byte);Move the turtle forward by selected number of steps.
parameters: |
TurtleHide | procedure TurtleHide;Hides the turtle. |
TurtleHome | procedure TurtleHome;Move the turtle to the home position (pointing up in the centre). |
NeoSetCursorXY | procedure NeoSetCursorXY(x,y:word);Positions the display cursor at x,y.
parameters: |
NeoShowCursor | procedure NeoShowCursor(show:byte);Shows or hides the mouse cursor.
parameters: |
NeoReadMouse | procedure NeoReadMouse;Returns the mouse position (screen pixel, unsigned) in neoMouseX, neoMouseY buttonstate in neoMouseButton (button 1 is 0x1, 2 0x2 etc., set when pressed), scrollwheelstate in neoMouseWheel as uint8 which changes according to scrolls. |
NeoIsMousePresent | function NeoIsMousePresent:boolean;returns true if mouse is plugged and detected.
returns: |
NeoSelectCursor | procedure NeoSelectCursor(shape:byte);Select a mouse cursor from predefined shapes.
parameters: |
NeoBlitterBusy | function NeoBlitterBusy:boolean;used to check availability and transfer completion.
returns: |
NeoBlitterCopy | procedure NeoBlitterCopy(src:cardinal;dst:cardinal;len:word);Copy the block of memory. Allows transfer of data in between 6502 RAM, Video RAM and Graphics RAM. The upper 8 bits of the address are : 6502 RAM ($00xxxx) VideoRAM ($8xxxxx) Graphics RAM($90xxxx). Sets error flag if the transfer is not possible (e.g. illegal write addresses).
parameters: |
NeoBlitterXCopy | procedure NeoBlitterXCopy(action:byte;src,dest:pointer);Copy a source rectangular area to a destination rectangular area. It's oriented toward copying graphics data, but can be used as a more general-purpose memory mover. The source and target areas may be different formats, and the copy will convert the data on the fly. The upper 8 bits of the address are : 6502 RAM ($00xxxx) VideoRAM ($8xxxxx) Graphics RAM($90xxxx).
parameters: |
NeoBlitImage | procedure NeoBlitImage(action:byte;src:pointer;x,y:word;format:byte);Blits an image from memory onto the screen. The image will be clipped, so it's safe to blit partly (or fully) offscreen-images.
parameters: |
NeoInitEditor | procedure NeoInitEditor;Initialises the editor |
NeoReenterEditor | procedure NeoReenterEditor;Re-enters the system editor. Returns the function required for call out, the editors sort of ’call backs’ - see editor specification |