; ************** Orzunoid On-Calc Universe Editor ************************ .nolist #include "ion.inc" #include "keys.inc" .list #ifdef TI83P .org progstart-2 .db $BB,$6D TEXT_MEM = $8508 APD_BUF = $86EC MUL_HL = $4276 #else .org progstart TEXT_MEM = $80c9 APD_BUF = $8265 MUL_HL = $4382 #endif xor a jr nc,Start progdesc: .db "OrzEdit v1.0",0 temp_data =APD_BUF+200 data =APD_BUF+200 NewVarName =APD_BUF var_pointer =APD_BUF+19 x =APD_BUF+21 y =APD_BUF+22 timer =APD_BUF+23 Start: ld a,5 ld (NewVarName),a get_variable: ;Test variable's existence bcall(_clrlcdf) ld de,$0200 ld hl,ProgDesc call DTX ld de,$0001 ld hl,nameinput call DTX call Write ld hl,NewVarName ; the name of the prog bcall(_mov9toop1) bcall(_chksysvar) ;Find the prog jp nc,var_already_exists ld hl,124 call CreateWorldVar ret c ex de,hl inc hl inc hl ; skip the size ld (hl), 5 inc hl xor a ld (hl), a ld hl,APD_BUF+500 ld de,APD_BUF+501 ld (hl),a ld BC, 120 ldir ; copy the level data jr good_var var_already_exists: ex de,hl call LoadDataFromVar ld a,h or a ret nz ld a,l cp 5 ret nz good_var: ld hl,APD_BUF+500 ld (var_pointer),hl ;Test if it's an OOCE level ; ************** Editor Main Screen ************************************** main_section: xor a ld (x),a ld (y),a ;Display main screen bcall(_clrlcdf) ld de,$0200 ld hl,ProgDesc call DTX ld de,$0001 ld hl,title_screen call DTX main_loop: ;Read user input bcall(_getcsc) cp G_CLEAR jp z,SaveVarInfo cp G_1 jr z,edit_first cp G_2 jr z,edit_second cp G_3 jr z,edit_third cp G_4 jr z,edit_fourth cp G_5 jr z,edit_fifth jr main_loop edit_fourth: ;Selects level to edit ld e,72 jr edit_level edit_fifth: ld e,96 jr edit_level edit_first: ld e,0 jr edit_level edit_second: ld e,24 jr edit_level edit_third: ld e,48 ; ************** Actual Editing Screen *********************************** edit_level: ;Decodes level from file ld hl,(var_pointer) ld d,0 add hl,de push hl call actual_level_loader edit_loop: set 7, (iy+$14) ;Write Text to GRAPH_MEM ld HL, editor_message ld B, 5 ld DE, $1C0F call Disp5 ld DE, $1C2C call Disp5 res 7, (iy+$14) ;Stop writing to graph_mem bcall(_getcsc) cp G_ENTER jp z,save_levels ld hl,x cp G_LEFT jr nz,noleft dec (hl) noleft: cp G_RIGHT jr nz,noright inc (hl) noright: inc hl cp G_UP jr nz,noup dec (hl) noup: cp G_DOWN jr nz,nodown inc (hl) nodown: push af ld hl,x ld a,(hl) cp 255 jp z,fixleft cp 12 call z,fixright donefix2 ld (hl),a ld b,a inc hl ld a,(hl) and 7 add a,a ;x2 add a,a ;x4 ld c,a add a,a ;x8 add a,c ;x12 add a,b ld c,a ld b,0 ld hl,data add hl,bc pop af cp G_YEDIT jr nz,nof1 ld (hl),0 nof1: cp G_WINDOW jr nz,nof2 ld (hl),1 nof2: cp G_ZOOM jr nz,nof3 ld (hl),2 nof3: cp G_TRACE jr nz,nof4 ld (hl),3 nof4: ld ix,GRAPH_MEM ld hl,temp_data ld b,8 rs_outer:push bc ld b,12 rs_inner:ld a,(hl) or a jr z,clear_block dec a jp z,draw_block dec a jp Z,draw_block_tough ld (ix+0),255 ld (ix+12),255 ld (ix+24),255 ld (ix+36),255 ok: inc hl inc ix djnz rs_inner ld de,36 add ix,de ; ld de,4 ; add hl,de pop bc djnz rs_outer ld hl,timer ld a,(hl) inc a ld (Hl),a rra jr c,noflicker ld hl,x ;Draw positioning dot ld b,(hl) inc hl ld a,(hl) and 7 add a,a ;x2 add a,a ;x4 add a,a ;x8 ld c,a add a,a ;x16 add a,c ;x24 ld h,0 add a,a rl h add a,b ld l,a ld de,GRAPH_MEM+12 add hl,de ld a,(hl) xor %00011000 ld (hl),a ld de,12 ;16 add hl,de ld (hl),a noflicker: bcall(_copygbuf) ld hl,GRAPH_MEM ld (hl),0 ld de,GRAPH_MEM+1 ld bc,767 ldir jp edit_loop fixleft: ld a,11 jp donefix2 fixright: xor a ret clear_block: ld (ix+0),0 ld (ix+12),0 ld (ix+24),0 ld (ix+36),0 jp ok draw_block: ld (ix+0),255 ld (ix+12),129 ld (ix+24),129 ld (ix+36),255 jp ok draw_block_tough: ld (ix+0),255 ld (ix+12),195 ld (ix+24),195 ld (ix+36),255 jp ok save_levels: pop de ld b,24 ld hl,temp_data loop: xor a push bc ld b,4 loopi: add a,a add a,a or (hl) inc hl djnz loopi pop bc ld (DE),a inc de djnz loop jp main_section Disp5: ld B, 5 Disp: ld A, D add A, 6 ld D, A ld (pencol), DE bcall(_vputs) djnz Disp ret actual_level_loader: ld b,24 ;Copy the map ld de,data set_up_1: push bc ld b,4 ld c,(hl) loop_row: rlc c rlc c ld a,c and 3 ld (de),a inc de djnz loop_row inc hl pop bc djnz set_up_1 ret DTX: ld (currow),de bcall(_puts) ret ; ************** OOCE Text Messages ************************************** nameinput: .db "Type the name of" .db "a level to edit:",0 title_screen: .db "1)Edit 1st Level" .db "2)Edit 2nd Level" .db "3)Edit 3rd Level" .db "4)Edit 4th Level" .db "5)Edit 5th Level" .db "CLEAR) Exit",0 editor_message: .db "Y=",0 .db "WINDOW",0 .db "ZOOM",0 .db "TRACE",0 .db "ENTER",0 .db ": Clear Brick",0 .db ": Reg. Brick",0 .db ": 2-Hit Brick",0 .db ": Hard Brick",0 .db ": Exit Level",0 Write: ld hl,NewVarName+1 ld (hl),0 ld de,NewVarName+2 ld bc,8 ldir ld hl,$0404 ld (currow),hl ld hl, NewVarName+1 push hl ld b,8 space_loop: ld (hl), ' ' inc hl djnz space_loop pop ix enter_name_loop: bcall(_getcsc) or A jr z,enter_name_loop cp $38 jr z,backup SUB 9 ret z dec a jp m,enter_name_loop ld hl,chartable ld e,a ld d,0 add hl,de ld a,8 cp b jr z,enter_name_loop ld a,(hl) or a jr z,enter_name_loop ld (ix),a bcall(_putc) inc b inc ix jr enter_name_loop backup: xor a cp b jr z,enter_name_loop dec b dec ix ld a,' ' ld (ix),a ld hl,curcol dec (hl) bcall(_putc) dec (hl) jr enter_name_loop chartable: .db "8WRMH6" .DB "780VQLG901ZUPKFC" .DB "23YTOJEBX45SNIDA" .DB "61234567" LoadDataFromVar inc hl inc hl ld c,(hl) inc hl ld b,(hl) inc hl push bc ld DE, APD_BUF+500 ld BC, 120 ldir pop hl ret SaveStuff2 ex de,hl inc hl inc hl ; skip the size ld (hl), 5 inc hl ld (hl), 0 inc hl ; Plain Jump level header ex de,hl ld HL, APD_BUF+500 ld BC, 120 ldir ; copy the level data ret CreateVar push hl push de pop hl bcall(_mov9toop1) pop hl bcall(_createprog) ;Create the prog ld (hl),6 ;lock prgm ret SaveVarInfo: ld hl,124 CreateWorldVar: ;HL = size of var to create, NewVarName contains name ; NewVarName must not be in program code.. should be ; in APD_BUF or graphmem or similar push hl ld hl,NewVarName bcall(_mov9toop1) bcall(_chksysvar) ccf pop hl jr c,SaveStuff2 ;return if var already exists ret c ;return if not ld de,NewVarName jr CreateVar ;create the variable ;now DE = addr of variable and HL = addr of VAT entry .end