Listado de funciones externas
Comandos por catalogar o descartar:
Sintaxis del lenguaje
GO TO, CONTINUE, IF, STOP, FOR, NEXT, TO, STEP, GOSUB, RETURN, DEF, DIM, AND, OR, NOT, XOR, REM, BREAK, NEW, CLEAR,
Por catalogar
RANDOMIZE, RND, CODE, USR, BIN, ;, TAB, AT, LINE, CLEAR, BEEP, PLAY, SAVE, LOAD, VERIFY, MERGE,
Descartadas
READ, DATA, RESTORE, VAL,
Sugerencias de comandos externos:
DIRMEM = Direccion de memoria de una variable, array, etc. MEMCOPY, MEMSET = Transferencias de memoria GETPIXEL, PUTPIXEL = Leer/Modificar pixel X,Y DRAWTILE8X8, DRAWTILE16X16 = Dibujar UDG de 8x8 o 16x16 en posición Low-res (32x24). GETTILE8X8, GETTILE16X16 = Leer UDG de 8x8 o 16x16 en posición Low-res (32x24). DRAWTILEMAP8X8, DRAWTILEMAP16X16 = Dibujar un mapa de tiles 8x8 ó 16x16 en posición Low-Res (32x24) INKEY$_RAW = Lectura raw de teclado (scancodes, sin traducir a ASCIIs). PEEK16, POKE16 = Lectura/Escritura de 2 bytes consecutivos de memoria. LISTS, STACKS, QUEUES, RINGS = Funciones de pilas, colas, listas y ringbuffers de enteros (IDs). STRUCT = Estructuras de elementos enteros accesibles por (IX+N). PIXELOFFSET, ATTRIBOFFSET, NEXTLINEOFFSET = Offset de un pixel X,Y en videoram o en zona de atributos. HALT = Espera al retrazo de la pantalla (HALT en asm).
Formato de las llamadas
Nota: Este tema está relacionado con la convención de llamada a subrutina.
El formato para las llamadas externas será (…).
Ejemplo:
;---------------------------------------------------------------------- ; FUNCTION: Function description ; ; INPUT: (register list) as (what they represent) ; OUTPUT: (register list) as (value) ; Uses: (register list) ; Contributed by user - date ;----------------------------------------------------------------------
Funciones de teclado
INKEY$
PAUSE
Funciones gráficas
CLS
;---------------------------------------------------------------------- ; CLS: Clears the screen with the char and attribute specified ; ; INPUT: (DE) as (char,attrib) in stack ; OUTPUT: None ; Uses: D, E, HL, A, A_shadow ; ; Contributed by sromero - 05-02-2008 ;---------------------------------------------------------------------- CLS: pop hl ; hl = return address ex (sp), hl ; hl = x,y ex de, hl ; de = x,y and (sp) = RETADDR ld a, e ex af, af ; a_shadow = attribute ld a, d ; a = character ld hl, 16384 ld (hl), a ld de, 16385 ld bc, 6143 ldir ex af, af ld hl, 16384+6144 ld (hl), a ld de, 16384+6145 ld bc, 768 ldir ret
PLOT
DRAW
POINT
ATTR
;---------------------------------------------------------------------- ; ATTR: Returns ATTRIBUTE at (x,y) position ; x,y is (0-N) ; ; INPUT: (DE) as (x,y) in stack ; OUTPUT: A = ATTR (x,y) ; Uses: DE, HL, A ; ; Contributed by sromero - 05-02-2008 ;---------------------------------------------------------------------- ATTR: pop hl ; hl = return address ex (sp), hl ; hl = x,y ex de, hl ; de = x,y and (sp) = RETADDR ; calc start address in DE (as (32*y) + x) ld h, 0 ld l, d add hl, hl ; HL = HL*2 add hl, hl ; HL = HL*4 add hl, hl ; HL = HL*8 add hl, hl ; HL = HL*16 add hl, hl ; HL = HL*32 ld b, 88 ld c, e add hl, bc ld a, (hl) ret
SETATTR (NEW)
;---------------------------------------------------------------------- ; SETATTR: Sets ATTRIBUTE at (x,y) position with value "v" ; x,y is (0-N) ; ; INPUT: (DE), (BC) as (x,y), (0,attribute) in stack ; OUTPUT: A = ATTR (x,y) ; Uses: DE, BC, HL, A ; Contributed by sromero - 05-02-2008 ;---------------------------------------------------------------------- SETATTR: pop hl ; hl = return address pop bc ; C = value (B value is ignored) ex (sp), hl ; hl = x,y ex de, hl ; de = x,y and (sp) = RETADDR ; calc start address in DE (as (32*y) + x) ld h, 0 ld l, d add hl, hl ; HL = HL*2 add hl, hl ; HL = HL*4 add hl, hl ; HL = HL*8 add hl, hl ; HL = HL*16 add hl, hl ; HL = HL*32 ld d, 0 add hl, de ld de, 22528 add hl, de ld a, c ld (hl), a ret
CIRCLE
Funciones de texto
CHR$
STR$
LEN
INPUT
Funciones "Inline"
POKE
;---------------------------------------------------------------------- ; POKE: Writes an 8 bit value in a 16 bit memory address ; ; INPUT: Address and Value directly assembled ; OUTPUT: None ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- POKE: LD (ADDRESS), VALUE
PEEK
;---------------------------------------------------------------------- ; PEEK: Reads an 8 bit value from a 16 bit memory address ; ; INPUT: Address directly assembled ; OUTPUT: A as value (register) ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- PEEK: LD A, (ADDRESS)
IN
;---------------------------------------------------------------------- ; IN: Reads a value from an I/O port. ; ; INPUT: Value Directly assembled ; OUTPUT: A as value (register) ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- IN: in a, (PORT)
OUT
;---------------------------------------------------------------------- ; OUT: Sends a value to an I/O port. ; ; INPUT: C, A as port,value (registers) ; OUTPUT: None ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- OUT: out (c), a
BORDER
;---------------------------------------------------------------------- ; BORDER: Clears the border with a given value ; ; INPUT: A as value (register) ; OUTPUT: None ; ; Contributed by foro.speccy.org - 01-02-2008 ;---------------------------------------------------------------------- BORDER: out (FEh), a
SETBIT (new)
;---------------------------------------------------------------------- ; SETBIT: Sets to 1 bit N in a given variable ; ; INPUT: ADDRESS of var, and BITNUM directly assembled ; OUTPUT: None ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- SETBIT: ld hl, ADDRESS set BITNUM, (hl)
RESETBIT (new)
;---------------------------------------------------------------------- ; RESETBIT: Sets to 0 bit N in a given variable ; ; INPUT: ADDRESS of var, and BITNUM directly assembled ; OUTPUT: None ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- RESETBIT: ld hl, ADDRESS res BITNUM, (hl)
TESTBIT (new)
;---------------------------------------------------------------------- ; TESTBIT: Checks if bit N in a given variable is 0 or 1 ; ; INPUT: ADDRESS of var, and BITNUM directly assembled ; OUTPUT: A = 0 or 1 ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- TESTBIT: xor a ; a = 0 ld hl, ADDRESS bit BITNUM, (hl) jr z, 1 ; jr z, $+1 (jump the INC opcode) inc a ; ZF = 0 -> bit not 0 -> a = 1 ; ZF = 1 -> bit = 0 -> a = 0
SHIFT_LEFT (new)
;---------------------------------------------------------------------- ; SHIFT_LEFT (<<): Aritmetical Shift Left (INT VARIABLE = VARIABLE*2) ; ; INPUT: DE as INTEGER register ; OUTPUT: DE rotated left ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- SHIFT_LEFT: SLA E RL D ; IX VERSION: Check which one is faster or better: ; ; LD IX, ADDRESS ; SLA (IX) ; RL (IX+01H)
SHIFT_RIGHT (new)
;---------------------------------------------------------------------- ; SHIFT_RIGHT (>>): Aritmetical Shift Right (INT VARIABLE = VARIABLE/2) ; ; INPUT: DE as INTEGER register ; OUTPUT: DE rotated right ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- SHIFT_RIGHT: SRA D RR E ; IX VERSION: Check which one is faster or better: ; ; LD IX, ADDRESS ; SRA (IX+01H) ; RR (IX)
A_AND (new)
;---------------------------------------------------------------------- ; A_AND (&): Logical AND in a 16 bit variable ; ; INPUT: MEMORY_ADDRESS as destination, DE as 16 bit AND value ; OUTPUT: Modifies Memory address ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- A_AND: LD A, E AND (ADDRESS) LD A, D AND (ADDRESS+1)
A_OR (new)
;---------------------------------------------------------------------- ; A_OR (|): Logical OR in a 16 bit variable ; ; INPUT: MEMORY_ADDRESS as destination, DE as 16 bit OR value ; OUTPUT: Modifies Memory address ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- A_OR: LD A, E OR (ADDRESS) LD A, D OR (ADDRESS+1)
A_XOR (new)
;---------------------------------------------------------------------- ; A_XOR (^): Logical XOR in a 16 bit variable ; ; INPUT: MEMORY_ADDRESS as destination, DE as 16 bit XOR value ; OUTPUT: Modifies Memory address ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- A_XOR: LD A, E XOR (ADDRESS) LD A, D XOR (ADDRESS+1)
Modificación de variables internas
Modificarán variables internas tipo “ZXB_CURRENT_ATTRIB” para ser usadas luego en PRINT, componiendo su valor con el de INK, PAPER, etc según qué dato se haya cambiado. Por ejemplo, una llamada a “INK 7”, metería el valor 7 en los 3 bits más bajos de la variable interna ZXB_CURRENT_ATTRIB.
INK
;---------------------------------------------------------------------- ; INK: Changes ZXB_CURRENT_ATTRIB bits 0-2 (INK) ; ; INPUT: Value directly assembled ; OUTPUT: None ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- INK: LD A, 248 ; Clear bits 0-2 AND (ZXB_CURRENT_ATTRIB) ; of ZXB_CURRENT_ATTRIB LD A, VALUE AND 7 ; Clear bits 7-3 of value OR (ZXB_CURRENT_ATTRIB) ; Change ink in ZXB_CURRENT_ATTRIB
PAPER
;---------------------------------------------------------------------- ; PAPER: Changes ZXB_CURRENT_ATTRIB bits 3-6 (PAPER) ; ; INPUT: Value directly assembled ; OUTPUT: None ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- PAPER: LD A, 199 ; Clear bits 3-6 AND (ZXB_CURRENT_ATTRIB) ; of ZXB_CURRENT_ATTRIB LD A, VALUE AND 7 ; Clear bits 7-3 of value SLA SLA SLA ; Shift Left A (3 times) OR (ZXB_CURRENT_ATTRIB) ; Change paper in ZXB_CURRENT_ATTRIB
BRIGHT
;---------------------------------------------------------------------- ; BRIGHT: Changes ZXB_CURRENT_ATTRIB bit 6 (BRIGHT) ; ; INPUT: Value directly assembled ; OUTPUT: None ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- BRIGHT: LD A, 191 ; Clear bits 7 and 5-0 AND (ZXB_CURRENT_ATTRIB) ; of ZXB_CURRENT_ATTRIB LD A, VALUE RRC A RRC A ; Bit 0 -> Bit 6 AND 191 ; Clear bits 7 and 5-0 OR (ZXB_CURRENT_ATTRIB) ; Change bright in ZXB_CURRENT_ATTRIB
FLASH
;---------------------------------------------------------------------- ; FLASH: Changes ZXB_CURRENT_ATTRIB bit 7 (FLASH) ; ; INPUT: Value directly assembled ; OUTPUT: None ; ; Contributed by sromero - 06-02-2008 ;---------------------------------------------------------------------- FLASH: LD A, 127 ; Clear bits 6-0 AND (ZXB_CURRENT_ATTRIB) ; of ZXB_CURRENT_ATTRIB LD A, VALUE RRC A ; Bit 0 -> Bit 7 AND 127 ; Clear bits 6-0 OR (ZXB_CURRENT_ATTRIB) ; Change flash in ZXB_CURRENT_ATTRIB
INVERSE
OVER
Funciones matemáticas
SGN
ABS
INT
SQR
FN
^
PI
EXP
LN
SIN
COS
TAN
ASN
ACS
ATN
(etc.)