home *** CD-ROM | disk | FTP | other *** search
- ;OrzEd-IC now uses the consolidated ACZ includes available with AsmStudio 3.1 or from the ACZ
- ; homepage at http://acz.calc.org/
- #include "ram86.h"
- #include "rom86.h"
- #include "asm86.h"
-
- #define lTable1 progEnd
- #define lTable2 progEnd + $20
- #define lTable3 progEnd + $40
-
- curLevelChar = $E748
- curLevel = $E749
- curOffset = $E74B
-
- .org _asm_exec_ram
- nop ;Mark program as AShell 1.1 compatable.
- jp AsmStart ;Jump to program init routine.
- .dw 0 ;Table version 0.
- .dw strDesc ;Pointer to description string.
-
- goThree:
- ld a, '3' ;For display.
- ld de, $0040 ;Get the address of the third level.
- jr goNum
- goTwo:
- ld a, '2' ;For display.
- ld de, $0020 ;Get the address of the second level.
- jr goNum
- goOne:
- ld a, '1' ;For display.
- ld de, $0000 ;Get the address of the first level.
- goNum:
- ld (curLevelChar), a ;This is read to get level display character.
- ld (curLevel), de ;Write it to the current level address.
- jr preMain ;Redisplay screen before continuing.
-
- lL_NoProg:
- ld de, strNoProg
- jp dispMsg
- lL_NotValid:
- ld de, strNotValid
- jp dispMsg
-
- AsmStart:
- call _runindicoff
- nL_Restart:
- call _clrScrn
- ld a, '1' ;This is just the easiest way of keeping track of
- ld (curLevelChar), a ; the current level number.
-
- loadLevel:
- call nameLevel ;Get name to load from.
- ld hl, strName ;Put level set title into _OP1
- rst 20h
- ld a, (intNameLen)
- ld (_OP1 + 1), a
- rst 10h ;Gets var info if it exists.
- jr c, lL_NoProg ;If it doesn't, generate an error.
- and $1F ;Mask out flags
- cp $12 ;Is it a program?
- jr nz, lL_NotValid ;If not, generate an error.
- ld a, b ;move bde -> ahl
- ex de, hl
- call _load_ram_ahl ;Load appropriate RAM page.
- ld c, (hl)
- inc hl
- ld b, (hl)
- lL_Find:
- ld a, $D0
- cpir
- xor a
- cp b
- jr nz, lL_Check
- cp c
- jr z, lL_NotValid ;If the signature doesn't exist, generate an error.
- lL_Check:
- ld a, $4F
- cp (hl)
- jr nz, lL_Find
- inc hl
- ld (curOffset), hl
- preMain:
- call reDispScreen ;Redraws the entire display.
- main:
- call _get_key
- dec a ;Move down 2 lines.
- jr z, mDown
- dec a ;Move left 4 bricks.
- jr z, mLeft
- dec a ;Move right 4 bricks.
- jr z, mRight
- dec a ;Move up 2 lines.
- jr z, mUp
- cp K_3 - 4 ;Load the third level.
- jr z, goThree
- cp K_2 - 4 ;Load the second level.
- jr z, goTwo
- cp K_1 - 4 ;Load the first level.
- jr z, goOne
- cp K_F1 - 4 ;Clear all levels and reset name.
- jp z, saveLevel
- cp K_F5 - 4 ;If F5 was pressed, just exit.
- jr nz, main
- doExit:
- ld a, $E1 ;Used to clear shiftflags 3-6.
- and (iy+shiftflags)
- ld (iy + shiftflags), a
- jp _clrScrn ;Clear screen before returning to shell.
-
- mDown:
- ld hl, (curOffset)
- ld de, $0008
- add hl, de
- ld (curOffset), hl
- jr preMain
-
- mLeft:
- ld hl, (curOffset)
- dec hl
- ld (curOffset), hl
- jr preMain
-
- mRight:
- ld hl, (curOffset)
- inc hl
- ld (curOffset), hl
- jr preMain
-
- mUp:
- ld hl, (curOffset)
- ld de, -$0008
- add hl, de
- ld (curOffset), hl
- jr preMain
-
- reDispScreen:
- push ix
- ld ix, 0 ;Start at the first brick.
- ld de, (curLevel) ;Load the memory offset of the current level.
- ld hl, (curOffset)
- add hl, de
- ex de, hl
- ld b, $20 ;We need to process 32 bytes.
- rDS_byte:
- push bc ;Save the byte count.
- ld b, 4 ;Four blocks per byte.
- ld a, (de) ;Get the current byte.
- ld c, a
- rDS_block:
- rlc c ;Bits 7 and 6 to 1 and 0.
- rlc c
- ld a, c
- and $03 ;Ignore bits 2-7.
- push de ;Can't lose this!
- call drawBlock ;Draw whatever type of block bits 1 and 0 represent.
- pop de ;Restore data pointer.
- inc ixl ;Increment the column.
- ld a, $10 ;If we hit the end of a line,
- cp ixl
- jr nz, rDS_goBlock
- ld ixl, 0
- inc ixh ;Increment the row.
- rDS_goBlock:
- djnz rDS_block ;If we're not done with this byte, loop.
- inc de ;Next byte!
- pop bc ;Restore the byte count.
- djnz rDS_byte ;If we're not done with the level, loop.
- ld hl, $0004 ;Just below the level display.
- ld (_curRow), hl
- ld a, (curLevelChar) ;Get level number (stored as a char)
- call _putc
- ld hl, strName ;Current name of the level set.
- call _puts
- ld hl, $3906 ;Set up menu at bottom of screen.
- ld (_penCol), hl
- ld hl, strSave
- call _vputs
- ld hl, $396C
- ld (_penCol), hl
- ld hl, strExit
- call _vputs
- pop ix ;Restore cursor position.
- ret
-
- saveLevel:
- ld hl, (curOffset)
- ld de, lTable1
- ld bc, $60
- ldir
- ld hl, strName ;Copy name w/o leading length into _OP1.
- rst 20h
- ld a, (intNameLen) ;Retrieve name length.
- ld (_OP1 + 1), a ;Add leading length byte (z80 is byte-reversed).
- rst 10h ;Check to see if it already exists.
- call _delvar ;If it does, generate an error.
- ld hl, $70 ;$60 data + $0E code + 2 asm header = $70.
- call _createprog ;Allocate program memory and create VAT entry.
- ld a, b ;Move bde -> ahl.
- ex de, hl
- call _load_ram_ahl ;Set RAM page and convert hl to ASIC.
- ld de, rawProg ;Copy program contents from _asm_exec_ram to
- ld bc, $70 ; the memory just allocated by _CREATEPROG.
- ex de, hl
- inc de ;Skip the size bytes.
- inc de
- ldir
- ld de, strGoodSave
- dispMsg:
- ld hl, $0005 ;Display below name.
- ld (_curRow), hl
- ex de, hl ;The offset of the text to display must be in de.
- call _puts ;Messages must be null-terminated.
- call _pause ;Hang around until they press a key.
- ld hl, $FE80 ;$FE80 = video address of the sixth line.
- ld de, $FE81
- ld bc, $017F
- ld (hl), 0
- ldir
- jp doExit
-
- nameLevel:
- ld a, (iy + shiftflags) ;Get shiftflags.
- or $50 ;Set shiftAlpha and shiftALock.
- ld (iy + shiftflags), a ;Save shiftslags.
- call _cursorOn ;We want the cursor displayed during text entry.
- ld de, strName + 2 ;Where the characters will go.
- ld a, (intNameLen) ;But first, we need to add the current offset.
- ld l, a
- ld h, 0
- add hl, de
- push hl ;I think _getkey screws with de and hl...
- nL_Loop: ;Used to update the display.
- ld hl, $0304 ;First letter of the name display.
- ld (_curRow), hl
- ld a, $20
- ld b, 9
- nL_OverWrite:
- call _putc
- djnz nL_OverWrite
- ld hl, $0304 ;First letter of the name display.
- ld (_curRow), hl
- ld hl, strName + 2 ;(Re)display the current name.
- call _puts
- nL_GetKey:
- call _getkey ;Use _getkey so we get Alpha handled for us.
- cp kEnter ;If it's enter, try to use this filename.
- jr z, nL_Next
- cp kDel ;If it's delete, remove the last charater typed.
- jr z, nL_Back
- add a, $14 ;L0 (font code) - k0 (key code) = 14 hex.
- cp L0 ;If it's less than 0, it's a bad character.
- jr c, nL_GetKey
- cp L9 + 1 ;If it's not more than 9, it's a numeral.
- jr c, nL_PrePutKey
- add a, $5 ;LcapA - kCapA = $14 + $5
- cp LcapA ;If it's less that A, it's a bad character.
- jr c, nL_GetKey
- cp LcapZ + 1 ;If it's not more than Z, it's a capital letter.
- jr c, nL_PutKey
- add a, $6 ;Lz - kz = $14 + $5 + $6
- cp Lz + 1 ;If it's not more than z, it's a lower-case letter.
- jr nc, nL_GetKey ;Otherwise, it's a bad character.
- jr nL_PutKey
- nL_PrePutKey: ;Need to make sure this isn't the first character.
- ld c, a ;We'll need a.
- ld a, (intNameLen) ;Grab the name length.
- ld b, 0 ;The first character cannot be a number.
- cp b
- jr z, nL_GetKey ;Numbers can't be the first character of a filename.
- ld a, c
- nL_PutKey:
- ld c, a ;We'll need a.
- ld a, (intNameLen) ;Grab the name length.
- ld b, 8 ;Filenames can't exceed 8 characters.
- cp b
- jr z, nL_GetKey
- inc a ;Increase the character count.
- ld (intNameLen), a ;Store the name length.
- pop hl ;Retrieve memory counter.
- ld (hl), c ;Load the character into memory.
- inc hl ;Increment the memory counter.
- push hl ;Store memory counter.
- jr nL_Loop ;Redisplay.
- nL_Back:
- ld a, (intNameLen) ;Grab the name length.
- ld b, 0 ;Can't backspace if it's there aren't any characters!
- cp b
- jr z, nL_GetKey
- dec a ;Decrease the character count.
- ld (intNameLen), a ;Store the name length.
- pop hl
- dec hl ;Decrement the memory counter.
- ld (hl), b ;Zero out the last character.
- push hl
- jr nL_Loop ;Redisplay
- nL_Next:
- ld a, (intNameLen) ;Grab the name length.
- ld b, 0 ;Can't use a zero-length name.
- cp b
- jr z, nL_GetKey
- call _cursorOff ;Get rid of cursor.
- pop hl
- ld (intNameLen), a ;Store the name length.
- ret
-
- drawBlock:
- call getOffset ;Change hl into screen offset.
- ld de, $0010 ;One full line on the screen.
- or a ;Is a 0?
- jr z, drawClear ;If so, clear the block.
- ld (hl), %11111111 ;All others start with $FF
- add hl, de
- dec a ;Was a 1?
- jr z, drawNorm ;If so, draw a normal block.
- dec a ;Was a 2?
- jr z, drawTough ;If so, draw a tough block.
- ld a, %11111111 ;Else, it's solid.
- ld (hl), a
- add hl, de ;Move down one line.
- ld (hl), a
- add hl, de
- ld (hl), a
- ret
- drawTough:
- ld (hl), %11000011 ;Second line of sprite.
- add hl, de
- ld (hl), %11000011 ;Third line of sprite.
- add hl, de
- ld (hl), %11111111 ;Last line of sprite.
- ret
- drawNorm:
- ld (hl), %10000001
- add hl, de
- ld (hl), %10000001
- add hl, de
- ld (hl), %11111111
- ret
- drawClear:
- ld (hl), a ;a is already 0.
- add hl, de
- ld (hl), a
- add hl, de
- ld (hl), a
- add hl, de
- ld (hl), a
- ret
-
- getOffset:
- push ix ;Copy ix into de.
- pop de
- ld l, d ;Change ixh into a 16-bit value in hl.
- ld h, 0
- ld d, $FC ;Load d with the upper byte of the screen offset.
- add hl, hl ;hl = Row * 64
- add hl, hl
- add hl, hl
- add hl, hl
- add hl, hl
- add hl, hl
- add hl, de ;hl = Screen Offset + Row * 64 + Column
- ret
-
- dataArea:
- strDesc:
- .db "Orzunoid Level Converter v.5b", 0
- strGoodSave:
- .db "Level set saved.", 0
- strName:
- .db ": Untitled", 0
- intNameLen:
- .db 8
- strNoProg:
- .db "No such file exists!", 0
- strNotValid:
- .db "Not a level set!", 0
- strNew:
- .db "New", 0
- strLoad:
- .db "Load", 0
- strSave:
- .db "Save", 0
- strTest:
- .db "Test", 0
- strExit:
- .db "Exit", 0
- rawProg:
- .db $8E, $28 ;Assembly program ID bytes (TI)
- ld de, $C012 ;Level storage in RAM.
- ld hl, $D754 ;_asm_exec_ram + $0C
- ld bc, $0062 ;# of bytes to copy (3 levels * $20 + 2)
- ldir
- ret
- .db $D0, $4F ;These tell Orzunoid that this is a valid level set.
-
- progEnd:
- .end
-