### Sequence Example: Copy Inputs to Outputs Source: https://github.com/leuat/trse/blob/master/Publish/tutorials/C64/Olimp/README.md This sequence demonstrates copying the value of input 'a' to output 'b', and then input 'b' to output 'a'. The '$' command terminates the sequence execution. ```Pseudocode ab ba $ ``` -------------------------------- ### Sequence Example: Conditional Blink Output Source: https://github.com/leuat/trse/blob/master/Publish/tutorials/C64/Olimp/README.md This sequence blinks an output ('a') with a 0.4-second period only if input 'a' is set to 1. It waits for input 'a' to become 1, then proceeds to blink output 'a' with a 1-second on/off period before finishing. Assumes cyclic sequence execution. ```Pseudocode *a 1a @02 0a @02 $ ``` -------------------------------- ### Sequence Example: Blink Output with 2s Period Source: https://github.com/leuat/trse/blob/master/Publish/tutorials/C64/Olimp/README.md This sequence blinks an output ('a') with a 2-second period. It sets output 'a' to 1, waits 1 second, sets output 'a' to 0, waits 1 second, and then finishes the sequence. Assumes cyclic sequence execution. ```Pseudocode 1a @0A 0a @0A $ ``` -------------------------------- ### Start IRQ Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt Starts an IRQ method, potentially with raster interrupts. Requires a procedure to handle the IRQ and a call to closeIRQ() to end it. ```TRSE RasterIRQ(myRaster(), 0, 1); // Assign myRaster with kernel (1) ... procedure myRaster(); begin startirq(1); // start IRQ with raster ... closeirq(); end(); ``` -------------------------------- ### Fill Memory with Value Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt The 'fill' function populates a specified number of bytes with a given value at a target memory address. It takes the starting address, the value to fill with, and the count of bytes (up to $ff) as parameters. Examples show filling with zeros and filling screen memory with blank characters. ```assembly fill(zeropage4, 0, 0); fill(^$0400, $20, 40); ``` -------------------------------- ### Arithmetic Instructions (e.g., ADD, SUB, MUL, DIV) Source: https://github.com/leuat/trse/blob/master/resources/text/opcodes_m68k.txt This category includes instructions for performing arithmetic operations. Examples include addition (ADD, ADDA, ADDI, ADDQ, ADDX), subtraction (SUB, SUBA, SUBI, SUBQ, SUBX), multiplication (MUL, MULU, MULS), and division (DIVU, DIVS). These instructions typically operate on data registers or memory locations and affect condition code flags. ```assembly ADD.B D0, D1 SUB.W #$10, (A0) MUL.L D2, D3 DIVU (A1)+, D4 ``` -------------------------------- ### Amiga and Atari ST Graphics Initialization Routines Source: https://github.com/leuat/trse/blob/master/resources/text/syntax.txt A set of initialization routines for 3D graphics operations, including matrix multiplication, polygon setup, line drawing, and projection, usable on both Amiga and Atari ST platforms. ```68000 Assembly InitMatmul3x3: ; Initializes 3x3 matrix multiplication routines. ; Input: Implicitly uses registers for matrix data. RET InitPoly: ; Initializes polygon rendering setup. ; Input: Implicitly uses registers for polygon data. RET InitLine: ; Initializes line drawing routines. ; Input: Implicitly uses registers for line parameters. RET InitMatmulVec: ; Initializes matrix-vector multiplication routines. ; Input: Implicitly uses registers for matrix and vector data. RET InitMatmulVecNormalZ: ; Initializes matrix-vector multiplication with normal and Z-buffer handling. ; Input: Implicitly uses registers for matrix, vector, normal, and Z data. RET InitProjectToScreen: ; Initializes routines for projecting 3D points to 2D screen coordinates. ; Input: Implicitly uses registers for projection parameters. RET InitP61PlayerInternal: ; Initializes internal routines for a P61 player (likely music player). ; Input: Implicitly uses registers for player settings. RET InitProjectAllVertices: ; Initializes routines for projecting all vertices of a model. ; Input: Implicitly uses registers for vertex data and projection settings. RET ``` -------------------------------- ### Miscellaneous Instructions (e.g., EXG, SWAP, EXT) Source: https://github.com/leuat/trse/blob/master/resources/text/opcodes_m68k.txt This category encompasses instructions that don't fit neatly into other groups. Examples include Exchange Register contents (EXG), Swap Register halves (SWAP), and Extend sign (EXT). These instructions provide specialized operations for data manipulation and register management. ```assembly EXG D0, D1 SWAP D2 EXT.W D3 ``` -------------------------------- ### TRSE Inline Assembly Example Source: https://context7.com/leuat/trse/llms.txt Demonstrates mixing high-level Pascal code with native assembly instructions within the TRSE programming language. This allows for performance-critical sections to be optimized using direct assembly. ```pascal program InlineAssembly; var value : byte; address : integer; result : integer; // Procedure with inline assembly procedure FastCopy() assembler; asm(" ; Fast memory copy routine lda #0 sta $d020 ldx #0 loop: lda source,x sta dest,x inx bne loop rts source: .byte 1,2,3,4,5 dest: .ds 5 "); end; // Inline directive for performance-critical code procedure SetBorder(color : byte); inline; begin asm(" lda color sta $d020 "); end; begin // Set border color using inline assembly value := 1; asm(" ; Direct assembly in main program lda #15 sta $d020 ; Border color sta $d021 ; Background color "); // Call assembly procedure FastCopy(); // Mixed code and assembly for value := 0 to 15 do begin SetBorder(value); // Assembly block with access to Pascal variables asm(" lda value asl a sta result "); end; end. ``` -------------------------------- ### C++ Programmatic TRSE Compilation Source: https://context7.com/leuat/trse/llms.txt Provides C++ code examples for programmatically triggering TRSE compilations using the CLI interface. It demonstrates how to set up compilation arguments and execute the compilation process, handling success and failure. ```cpp // Example: Using CLI interface in code #include "trc.h" #include int main(int argc, char *argv[]) { // Create CLI executor ClascExec cliExec(argc, argv); // Example argv: // argv[0] = "trc" // argv[1] = "-cli" // argv[2] = "op=project" // argv[3] = "project=demo.trse" // argv[4] = "input_file=main.ras" // argv[5] = "assemble=yes" // Perform compilation int result = cliExec.Perform(); if (result == 0) { qDebug() << "Compilation successful!"; } else { qDebug() << "Compilation failed!"; // Error output is printed to stdout } return result; } // Programmatic compilation example void CompileProject() { QSharedPointer settings(new CIniFile()); settings->Load("trse.ini"); QSharedPointer project(new CIniFile()); project->Load("myproject.trse"); QString sourceFile = "main.ras"; QString projectDir = QDir::currentPath() + "/"; SourceBuilder builder(settings, project, projectDir, sourceFile); QString source = Util::loadTextFile(sourceFile); if (builder.Build(source)) { qDebug() << "Build successful"; // Assemble to binary builder.Assemble(); if (builder.m_assembleSuccess) { qDebug() << "Assembly successful"; qDebug() << "Output:" << builder.m_filename; } } else { qDebug() << "Build failed"; qDebug() << builder.getOutput(); } } ``` -------------------------------- ### Move Screen Cursor Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt The 'moveto' function positions the screen cursor ('screenmemory') at a given x, y coordinate on the screen, using a specified high byte for the address. The example shows moving to position (0,5) and then filling the 5th row of screen bank 0 with values from 0 to 40. ```assembly moveto(0,5, $04); for i:=0 to 40 do screenmemory[i]:=i; ``` -------------------------------- ### Configure and Initialize C64 System Source: https://context7.com/leuat/trse/llms.txt This C++ snippet demonstrates how to create and configure a C64 system using the SystemC64 class. It loads settings from INI files, initializes preprocessor defines, displays system properties, lists memory map labels, and compresses a file using Exomizer if supported. Dependencies include Qt framework and custom system classes. ```cpp // Example: Creating and configuring a C64 system #include "source/Compiler/systems/systemc64.h" QSharedPointer settingsIni(new CIniFile()); settingsIni->Load("trse.ini"); QSharedPointer projectIni(new CIniFile()); projectIni->Load("myc64project.trse"); // Create C64 system SystemC64 c64System(settingsIni, projectIni); // System properties qDebug() << "Start address:" << QString::number(c64System.m_startAddress, 16); qDebug() << "Memory size:" << c64System.m_memorySize; qDebug() << "Is 8-bit:" << c64System.is8bit(); qDebug() << "Supports Exomizer:" << c64System.m_supportsExomizer; // Initialize preprocessor defines QHash defines; c64System.InitSystemPreprocessors(defines); qDebug() << "System defines:" << defines; // Memory map labels for (const SystemLabel& label : c64System.m_labels) { qDebug() << label.m_name << "Range: $" << QString::number(label.m_from, 16) << "- $" << QString::number(label.m_to, 16); } // Compress file with Exomizer (if supported) QString compressedFile = c64System.CompressFile("myprogram.prg"); qDebug() << "Compressed file:" << compressedFile; ``` -------------------------------- ### Get Bit Value Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt The 'GetBit' function checks a specific bit at a given memory address and returns either 0 or 1. It's useful for checking flags or the state of individual bits. The example shows checking if sprite 3 is active. ```assembly if (GetBit(SPRITE_BITMASK,3)==1) then ... ``` -------------------------------- ### Copy Memory Block Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt The 'memcpy' function copies a specified number of bytes from a source address (with an optional shift) to a destination address. It takes the source address, source shift, destination address, and the count of bytes (up to $ff) as parameters. Examples show copying screen memory and a block starting from $D800. ```assembly memcpy(^$0400, 0, $0480, 40); memcpy(^$D800+^40*^2, 0, ^$D800+^40*^3, 80); ``` -------------------------------- ### Check Key Press Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt The 'Keypressed' function checks if a specific key is pressed and returns 1 if it is, and 0 otherwise. It takes a key code as a parameter. The example demonstrates checking for the space bar press and includes a list of example key codes. ```assembly if (keypressed(KEY_SPACE)=1)then begin ... end; ``` -------------------------------- ### OK64 Graphics and Utility Methods Source: https://github.com/leuat/trse/blob/master/resources/text/syntax.txt A collection of methods for the OK64 platform, covering pixel and shape drawing, screen clearing, VSYNC waiting, color manipulation, palette setting, blitting, character printing, input handling, file operations, memory copying, and floating-point multiplication. ```assembly m; drawPixel; OK64; b,b,b m; drawLine; OK64; b,b,b,b,b m; drawCircleFilled; OK64; b,b,b,b m; drawRect; OK64; b,b,b,b,b m; drawPoly; OK64; b,b,b,b,b,b,b m; ClearScreen; OK64; b m; WaitForVsync; OK64; m; toColor; OK64; b,b,b m; setPalette; OK64; b,b,b,b m; blit; OK64; b,b,b,b,b,b m; PrintChar; OK64; ,b,b,b,b m; InputIRQ; OK64; p m; ResetFileList; OK64; m; ReadNextFile; OK64; m; LoadFile; OK64; m; MemCpyOKVC; OK64; b,b,b,b,b,b,b,b m; setDefaultPalette; OK64; m; fmul;OK64;b,b ``` -------------------------------- ### Load and Build TRSE Project Programmatically Source: https://context7.com/leuat/trse/llms.txt This C++ code snippet demonstrates how to load a TRSE project file, extract its settings, create a target system instance, initialize a compiler, parse source code, and build the project for the target system. It includes error handling for compilation and saving the generated assembly. ```cpp // Example: Loading and building a TRSE project #include "mainwindow.h" #include "source/Compiler/compilers/compiler.h" // Load project QString projectFile = "myproject.trse"; QSharedPointer projectIni(new CIniFile()); projectIni->Load(projectFile); // Get project settings QString system = projectIni->getString("system"); // "C64", "AMIGA", etc. QString mainFile = projectIni->getString("main_ras_file"); QString outputFile = projectIni->getString("output_file"); QString projectPath = projectIni->getString("project_path"); qDebug() << "System:" << system; qDebug() << "Main file:" << mainFile; // Create system instance AbstractSystem::System sysType = AbstractSystem::SystemFromString(system); QSharedPointer targetSystem = SystemFactory::CreateSystem(sysType, settingsIni, projectIni); // Initialize compiler Compiler compiler; compiler.m_projectIni = projectIni; compiler.m_settingsIni = settingsIni; // Load and parse source QString source = Util::loadTextFile(projectPath + "/" + mainFile); QStringList lines = source.split("\n"); compiler.Parse(source, lines, mainFile); // Build for target system if (compiler.Build(targetSystem, projectPath)) { qDebug() << "Compilation successful!"; // Get generated assembly QStringList assembly = compiler.m_assembler->m_source; // Save assembly QString asmFile = outputFile + ".asm"; QFile file(asmFile); if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream out(&file); for (const QString& line : assembly) { out << line << "\n"; } } } else { qDebug() << "Compilation failed!"; } ``` -------------------------------- ### Check Input/Variable for Value 0 Source: https://github.com/leuat/trse/blob/master/Publish/tutorials/C64/Olimp/README.md This 3-character command checks if an input (a-p) or a variable (2-9) is equal to 0. If the condition is true, execution jumps to a specified step; otherwise, it proceeds to the next step. The second character specifies the input/variable, and the third specifies the target step. ```Pseudocode %af - if input a is 0, jump to step f, otherwise go to next step %9m - if variable 9 is 0, jump to step m, otherwise go to next step ``` -------------------------------- ### TRSE Built-in Method: ClearBitmap Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt Clears a specified amount of memory starting from a given address. The size is calculated as 256 bytes multiplied by the fill size parameter. ```TRSE Pseudo-code ClearBitmap($2000, 32); // Clears 8192 (32*256) bytes at $2000 ``` -------------------------------- ### P61 Module Core Functions Source: https://github.com/leuat/trse/blob/master/resources/text/syntax.txt Core functions of the P61 module, including initialization, playback, memory poking, and screen synchronization. ```APIDOC ## P61 Module Core Functions ### Description Provides essential functions for initializing and controlling the P61 module, including playback, memory access, and vertical blank synchronization. ### Method Various (see individual function descriptions) ### Endpoint N/A (internal module functions) ### Parameters N/A (internal module functions) ### Request Example N/A ### Response N/A #### Functions: - **InitP61Module(Amiga)**: Initializes the P61 module on Amiga. - **PlayP61Module(Amiga)**: Plays the P61 module on Amiga. - **Poke8(Amiga, ATARI520ST; a,i,b)**: Pokes a byte to memory. - **Poke16(Amiga, ATARI520ST; a,i,i)**: Pokes a 16-bit word to memory. - **Peek16(M68000; a,i)**: Peeks a 16-bit word from memory. - **Peek8(M68000; a,i)**: Peeks a byte from memory. - **Poke32(Amiga, ATARI520ST; a,i,l)**: Pokes a 32-bit word to memory. - **WaitVerticalBlank(Amiga, ATARI520ST)**: Waits for the vertical blank period. - **SetCopperList32(Amiga; a, a)**: Sets a Copper list for Amiga. - **ApplyCopperList(Amiga)**: Applies the Copper list on Amiga. - **memcpy(Amiga, ATARI520ST; a, l,a,l, l,i)**: Copies memory block. - **memcpyunroll(Amiga, ATARI520ST; a, l,a,l, l,i)**: Copies memory block with unrolling. - **setpalette(Amiga, ATARI520ST; a, a, l)**: Sets the color palette. - **ablit(Amiga; a,a,i, i,i,i,i,l,i,i,i)**: Performs an accelerated blit operation. - **fblit(Amiga; a,a,i, i,i,i,i,l,i,i,i)**: Performs a fast blit operation. - **getKey(C64, MEGA65, C128, VIC20)**: Gets a key press from input devices. - **EnableInterrupt(Amiga, ATARI520ST; i)**: Enables interrupts. - **pusha(Amiga, ATARI520ST)**: Pushes all registers onto the stack. - **popa(Amiga, ATARI520ST)**: Pops all registers from the stack. - **ToPointer(Amiga, ATARI520ST; l)**: Converts a value to a pointer. - **swap(Amiga, ATARI520ST; a,a,b)**: Swaps two memory locations. ``` -------------------------------- ### Increment Zeropage Pointer Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt The 'inczp' function increases a specified zeropage pointer by a given value. It takes the zeropage variable and the value to increase by as parameters. The example shows increasing 'zeropage2' by 64 bytes. ```assembly inczp(zeropage2, 64); ``` -------------------------------- ### IO Routines Source: https://github.com/leuat/trse/blob/master/resources/text/syntax.txt Routines for loading and initializing data, particularly for C64, MEGA65, and PLUS4 systems. ```APIDOC ## KrillLoad ### Description Loads Krill data for C64, MEGA65, or PLUS4. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## KrillLoadCompressed ### Description Loads compressed Krill data for C64, MEGA65, or PLUS4. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## InitKrill ### Description Initializes Krill for C64, MEGA65, or PLUS4. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ``` -------------------------------- ### Decrement Zeropage Pointer Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt The 'deczp' function decreases a specified zeropage pointer by a given value. It takes the zeropage variable and the value to decrease by as parameters. The example shows decreasing 'zeropage2' by 64 bytes. ```assembly deczp(zeropage2, 64); ``` -------------------------------- ### For Loop Syntax Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt Implements loops with optional 'begin' blocks for multiple statements, step values, and page-specific execution. ```TRSE for a:=0 to 20 do begin screenMemory[a]:=b; incscreenx(40); end; for a:=0 to 16 do poke(SCREEN_BG_COL, 0, a); for a:=0 to 16 step 4 do .. for a:=0 to 4 onpage do ``` -------------------------------- ### Copy Inputs to Variables Source: https://github.com/leuat/trse/blob/master/Publish/tutorials/C64/Olimp/README.md This 2-character command copies values from input groups to variables. The first character is '<', and the second specifies the group of 8 inputs (1-4) to be copied to variables 2-9. ```Pseudocode <1 - copy values of inputs a-h to variables 2-9 <4 - copy values of inputs I-P to variables 2-9 ``` -------------------------------- ### Check Input/Variable for Value 1 Source: https://github.com/leuat/trse/blob/master/Publish/tutorials/C64/Olimp/README.md This 3-character command checks if an input (a-p) or a variable (2-9) is equal to 1. If the condition is true, execution jumps to a specified step; otherwise, it proceeds to the next step. The second character specifies the input/variable, and the third specifies the target step. ```Pseudocode ?af - if input a is 1, jump to step f, otherwise go to next step ?9m - if variable 9 is 1, jump to step m, otherwise go to next step ``` -------------------------------- ### Set All Variables to Hexadecimal Value Source: https://github.com/leuat/trse/blob/master/Publish/tutorials/C64/Olimp/README.md This 3-character command sets all variables (2-9) to a specific binary value represented by two hexadecimal digits. The first character is '←', followed by two hexadecimal digits. ```Pseudocode ←AF - Set variables 2-9 to binary value 10101111 ``` -------------------------------- ### Copy Variables to Inputs Source: https://github.com/leuat/trse/blob/master/Publish/tutorials/C64/Olimp/README.md This 2-character command copies values from variables to input groups. The first character is '>', and the second specifies the group of 8 inputs (1-4) to which variables 2-9 will be copied. ```Pseudocode >1 - copy values of variables 2-9 to inputs a-h >4 - copy values of variables 2-9 to inputs I-P ``` -------------------------------- ### Decrunch Resource by Index Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt The DecrunchFromIndex function is used when data is crunched using a PAW file. It requires an address list as the first parameter and the index of the resource to decrunch as the second. The example shows calling DecrunchFromIndex with 'my_address' and 'i', followed by 'Pause()' and 'inc(i)'. ```assembly DecrunchFromIndex(my_address, i); Pause(); inc(i) ``` -------------------------------- ### Z80/Z180 Bit and Memory Manipulation Routines Source: https://github.com/leuat/trse/blob/master/resources/text/syntax.txt Routines for toggling and getting bits, filling memory blocks, and efficient memory copying. These are optimized for Z80 and Z180 processors, commonly found in Game Boy and other retro systems. They handle direct memory operations and can be configured for different memory regions. ```Z80 Assembly ToggleBit: ; Toggles a specific bit in a register. ; Input: Register 'a' (value), Register 'b' (bit mask) ; Output: Register 'a' (toggled value) XOR b RET GetBit: ; Retrieves the value of a specific bit from a register. ; Input: Register 'a' (value), Register 'b' (bit mask) ; Output: Register 'a' (bit value: 0 or 1) AND b RET fill: ; Fills a block of memory with a specified value. ; Input: Register 'a' (value to fill), Register 'b' (memory address), Register 'i' (count) PUSH HL LD HL, b LD BC, i LDIR ; This is a common Z80 instruction for block transfer POP HL RET MemCpy: ; Copies a block of memory from one location to another. ; Input: Register 'a' (source address), Register 'a' (destination address), Register 'i' (count) ; Note: This assumes HL is destination and DE is source in Z80 standard, adjust if needed. PUSH DE PUSH BC LD HL, a LD DE, a LD BC, i LDIR POP BC POP DE RET MemCpyCont: ; Continuous memory copy, likely for streaming data. ; Input: Register 'i' (count or data pointer) ; Implementation details would depend on specific use case. RET MemCpyOnHBLank: ; Memory copy optimized to occur during horizontal blanking interval. ; Input: Register 'a' (source), Register 'a' (destination), Register 'i' (count) ; This routine requires precise timing and synchronization with the display's HBLANK signal. RET MemCpyOnHBLank4: ; Similar to MemCpyOnHBLank, potentially optimized for 4-byte chunks or specific hardware. ; Input: Register 'a' (source), Register 'a' (destination), Register 'i' (count) RET MemCpyOnHBLankExp: ; Expanded version of HBLANK memory copy, possibly with more options or for different hardware. ; Input: Register 'a' (source), Register 'a' (destination), Register 'i' (count) RET EnableVBlank: ; Enables Vertical Blanking interrupts. ; No input/output specified, likely modifies interrupt enable registers. EI ; Enable Interrupts (example instruction) RET EnableTimer: ; Enables timer interrupts. ; No input/output specified, likely modifies timer control registers. RET Halt: ; Halts the CPU until an interrupt occurs. HALT RET Loop: ; Enters an infinite loop. ; No input/output specified. LOOP: JP LOOP SetSprite: ; Sets sprite attributes (position, tile, etc.). ; Input: Register 'a', 'b', 'b', 'b', 'b' (parameters for sprite setup) RET InitSprite: ; Initializes sprite data. ; Input: Register 'a', 'b', 'b', 'b', 'b' (parameters for sprite initialization) RET InitSpriteFromData: ; Initializes sprite data from a memory location. ; Input: Register 'a' (data address), 'a' (sprite data pointer), 'b', 'b', 'b', 'b' (parameters) RET UpdateMusic: ; Updates music playback. ; No input/output specified. RET LoadMusic: ; Loads music data. ; Input: Register 's' (music data pointer), 'b' (length) RET InitVBlank: ; Initializes Vertical Blanking interrupt handler. ; Input: Register 'p' (pointer to handler) RET InitTimer: ; Initializes Timer interrupt handler. ; Input: Register 'p' (pointer to handler) RET Push: ; Pushes a value onto the stack. ; Input: Implicitly uses a register to push. PUSH AF ; Example: Push AF register pair RET POP: ; Pops a value from the stack. ; Input: Implicitly uses a register to pop into. POP AF ; Example: Pop into AF register pair RET waitforhblank: ; Waits for the horizontal blanking interval. ; No input/output specified. RET joypad: ; Reads the state of the joypad. ; Input: Register 'a' (port address), 'a' (mask) ; Output: Register 'a' (joypad state) IN A, (a) AND a RET RasterIRQ: ; Sets up a Raster Interrupt. ; Input: Register 'p' (scanline) ; This routine is specific to systems like Amstrad CPC and VZ200. RET ``` -------------------------------- ### Turn Screen On - ScreenOn Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt Enables the display output, turning the screen on. This is used to restore visual output after it has been turned off. ```Assembly ScreenOn(); ``` -------------------------------- ### Jammer Debugging Tool Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt The 'jammer' function is a debugging tool that sets a specific background color and halts the processor if a given raster line is reached. It takes the raster line number and the jammer color as arguments. This helps in testing raster IRQ limits. The example sets the jammer for line 150 with a yellow background. ```assembly jammer(150, YELLOW); // crashes the processor with yellow bg if line 150 is hit ``` -------------------------------- ### TRSE Program: Hello World Source: https://context7.com/leuat/trse/llms.txt A basic 'Hello, World!' program written in the TRSE programming language. It demonstrates importing system units for screen and input, variable and constant declarations, clearing the screen, printing strings and numbers, and a simple input-driven loop. The syntax is Pascal-like. ```pascal program HelloWorld; // Import system units @use "system/screen" @use "system/input" // Variable declarations var message : string = ("Hello, TRSE World!", 0); counter : byte = 0; x, y : integer; // Constant declarations const MAX_COUNT : byte = 255; SCREEN_WIDTH : integer = 40; begin // Clear screen Screen::Clear(Screen::black, Screen::white); // Print message Screen::PrintString(#message, 10, 5); // Main loop while (counter < MAX_COUNT) do begin counter := counter + 1; // Update display Screen::PrintNumber(counter, 15, 10); // Check for keypress if (Input::KeyPressed(Input::KEY_SPACE)) then break; end; end. ``` -------------------------------- ### Screen Routines Source: https://github.com/leuat/trse/blob/master/resources/text/syntax.txt Routines for screen manipulation and drawing across various systems including C64, MEGA65, PLUS4, NES, and PET. ```APIDOC ## Tile ### Description Handles tile-based graphics operations for multiple systems. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## MoveTo ### Description Moves the cursor or drawing position on the screen for various systems. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## ScrollY ### Description Scrolls the screen vertically on C64, MEGA65, PLUS4, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## ScrollX ### Description Scrolls the screen horizontally on C64, MEGA65, PLUS4, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## hideborderx ### Description Hides the horizontal border on C64, MEGA65, PLUS4, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## hidebordery ### Description Hides the vertical border on C64, MEGA65, PLUS4, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## ClearScreen ### Description Clears the screen on multiple systems. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## ClearBitmap ### Description Clears a bitmap area on C64, MEGA65, PLUS4, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## SetMultiColorMode ### Description Sets the multicolor mode on C64, MEGA65, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## SetRegularColorMode ### Description Sets the regular color mode on C64, MEGA65, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## SetBitmapMode ### Description Sets the bitmap mode on C64, MEGA65, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## SetTextMode ### Description Sets the text mode on C64, MEGA65, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## SetBank ### Description Sets the memory bank on C64, MEGA65, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## ScreenOff ### Description Turns off the screen on C64, MEGA65, PLUS4, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## ScreenOn ### Description Turns on the screen on C64, MEGA65, PLUS4, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## CopyImageColorData ### Description Copies image and color data on C64, MEGA65, PLUS4, and C128. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## DrawTextBox ### Description Draws a text box on systems including C64, MEGA65, NES, VIC20, and PET. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## DrawColorTextBox ### Description Draws a colored text box on systems including C64, MEGA65, NES, VIC20, and PET. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ## BcdPrint ### Description Prints Binary Coded Decimal (BCD) numbers on various systems. ### Method N/A (assumed internal function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) N/A #### Response Example ```json {} ``` ``` -------------------------------- ### Enable All RAM Access Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt The 'EnableAllRam()' function makes all RAM on the C64 visible by modifying the first three bits of address $01. This is useful for reading from memory regions like $D000. It's crucial to restore the original value of address $01 after use. The example shows saving the original value, enabling all RAM, performing a memory copy, and then restoring the original value. ```assembly orgVal := peek(^$01,0); EnableAllRam(); memcpy(^$D000,0, ^$4000, 128); poke(^$01,0,orgVal); // Restore original value ``` -------------------------------- ### decrunch Data with incbin Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt This snippet demonstrates how to include binary data using 'incbin' and then decrunch it. It shows two ways to call the 'decrunch' function: one using a memory address and another using a variable holding the compressed data. Dependencies include the 'incbin' directive and the 'decrunch' function. ```assembly var compressed_data: incbin("my_data.bin",$8000); ... decrunch($8199); // OR decrunch(compressed_data); ``` -------------------------------- ### TRSE Program: Arrays and Records Source: https://context7.com/leuat/trse/llms.txt This TRSE program illustrates the usage of complex data structures, including arrays (1D and 2D) and records (structs). It defines custom types like 'Point' and 'Sprite', demonstrates array initialization and access, record instantiation and member access, and the use of pointers. It also includes examples of procedures with parameters and functions returning values. ```pascal program DataStructures; type // Record definition (struct) Point = record x, y : integer; color : byte; end; Sprite = record pos : Point; width, height : byte; data : pointer; end; var // Array declarations scores : array[10] of integer; grid : array[20, 20] of byte; // Record instances player : Sprite; enemies : array[5] of Sprite; // Pointer variables ptr : ^byte; dataPtr : ^integer; i, j : byte; // Procedure with parameters procedure InitSprite(var s : Sprite; xpos, ypos : integer); begin s.pos.x := xpos; s.pos.y := ypos; s.pos.color := 14; // Light blue s.width := 24; s.height := 21; end; // Function returning value function Distance(x1, y1, x2, y2 : integer) : integer; var dx, dy : integer; begin dx := x2 - x1; dy := y2 - y1; Distance := sqrt(dx*dx + dy*dy); end; begin // Initialize arrays for i := 0 to 9 do scores[i] := 0; // 2D array access for i := 0 to 19 do for j := 0 to 19 do grid[i, j] := (i + j) & 255; // Initialize records InitSprite(player, 160, 100); for i := 0 to 4 do begin InitSprite(enemies[i], i * 30, 50); enemies[i].pos.color := i + 1; end; // Pointer operations ptr := $D000; // Point to hardware register ptr^ := 255; // Dereference and assign // Record access player.pos.x := player.pos.x + 1; // Call function i := Distance(player.pos.x, player.pos.y, enemies[0].pos.x, enemies[0].pos.y); end. ``` -------------------------------- ### OK64 Graphics and System Constants Source: https://github.com/leuat/trse/blob/master/resources/text/syntax.txt Constants for the OK64 platform, including video controller addresses for randomization, VSYNC, execution, font settings, border control, input, file operations, blitting, and sound. ```assembly c; OKVC_RANDOM; OK64; a; $FFF0 c; OKVC_VSYNC; OK64; a; $FFEF c; OKVC_EXEC; OK64; a; $FF10 c; OKVC_FONT_BANK; OK64; a; $FFEE c; OKVC_FONT_WIDTH; OK64; a; $FFED c; OKVC_FONT_HEIGHT; OK64; a; $FFEC c; OKVC_BORDER_WIDTH; OK64; a; $FFEB c; OKVC_BORDER_HEIGHT; OK64; a; $FFEA c; OKVC_BORDER_COLOR; OK64; a; $FFE9 c; OKVC_INPUT_KEY; OK64; a; $FFE8 c; OKVC_FILE; OK64; a; $FF20 c; OKVC_SRC_PAGE; OK64; a; 0xFFE7 c; OKVC_DST_PAGE; OK64; a; 0xFFE6 c; OKVC_CURRENT_STRIP; OK64; a; 0xFFE5 c; OKVC_STRIP; OK64; a; 0xFE00 c; OKVC_BLIT_TYPE; OK64; a; 0xFFE4 c; OKVC_BLIT_ALPHAVAL; OK64; a; 0xFFE3 c; OKVC_BLIT_ALPHA ; OK64; b; 1 c; OKVC_BLIT_ADD ; OK64; b; 2 c; OKVC_CHANNEL1_VOL ; OK64; a; 0xFFE1 c; OKVC_CHANNEL2_VOL ; OK64; a; 0xFFE2 c; OKVC_OUTVAL ; OK64; a; 0xFFE0 ``` -------------------------------- ### Bitwise AND Operation Source: https://github.com/leuat/trse/blob/master/Publish/tutorials/C64/Olimp/README.md This 3-character command performs a bitwise AND operation. The first character is '&'. The second and third characters specify the operands, which can be inputs (a-p), variables (2-9), or constants (0-1). The result is stored in variable 9. ```Pseudocode &a2 - perform bitwise AND between input a and variable 2 and puts result in variable 9 &aD - perform bitwise AND between input a and input D and puts result in variable 9 ``` -------------------------------- ### Bitwise OR Operation Source: https://github.com/leuat/trse/blob/master/Publish/tutorials/C64/Olimp/README.md This 3-character command performs a bitwise OR operation. The first character is '='. The second and third characters specify the operands, which can be inputs (a-p), variables (2-9), or constants (0-1). The result is stored in variable 9. ```Pseudocode =a2 - perform bitwise OR between input a and variable 2 and puts result in variable 9 =aD - perform bitwise OR between input a and input D and puts result in variable 9 ``` -------------------------------- ### If Conditional Syntax Source: https://github.com/leuat/trse/blob/master/resources/text/Documentation.txt Provides basic conditional execution with optional 'begin' blocks and 'else' clauses. Supports forcing onpage/offpage branches and multiple logical conditions using 'and' and 'or'. ```TRSE if a>b then begin ... end; if a>b then begin ... end else a:=b; // do something if a>b onpage then begin // Force the branch to be fast/small, but requires less than 127 bytes of code ... if (a>b and (ba)) then begin ... ```