#include "asm86.h" #include "ti86asm.inc" #include "ti86ops.inc" _mov10b equ $427B _pause equ $4D43 _runoff equ $4AB1 _runon equ $4AAD _load_ram_ahl equ $462F .org _asm_exec_ram ;****************************Description*************************** nop jp Main_Menu .dw 0000 .dw Title_Str ;*****************************Main Menu**************************** Main_Menu: call _runoff call _clrScrn call _homeup ld hl,Title_Str1 set 3,(iy+5) call _puts res 3,(iy+5) ld hl,$0003 ld (_curRow),hl ld hl,Title_Str2 call _puts ld hl,$3900 ld (_penCol),hl ld hl,Menu_Str call _vputs Invert_The_Bottom_7_Lines: ld b,112 ld hl,$FF90 Draw_It: ld a,(hl) cpl ld (hl),a inc hl djnz Draw_It Main_Menu_GetLoop: call _getkey cp kF3 jr z,Keys_For_This_Program cp kF2 jp z,Edit_A_Old_Pic cp kF1 jp z,Make_A_New_Pic cp kF5 jp z,Exit_The_Program jp Main_Menu_GetLoop Keys_For_This_Program: call _clrScrn call _homeup ld hl,Help_Keys set 3,(iy+5) call _puts res 3,(iy+5) ld hl,$0A0D ld (_penCol),hl ld hl,Help_Keys_Sub1 call _vputs ld hl,$130C ld (_penCol),hl ld hl,Help_Keys_Sub2 call _vputs ld hl,$1C06 ld (_penCol),hl ld hl,Help_Keys_Sub3 call _vputs ld hl,$2505 ld (_penCol),hl ld hl,Help_Keys_Sub4 call _vputs call _pause jp Main_Menu Edit_A_Old_Pic: call _clrScrn call _homeup call Load_A_Pic_Name jp z,Main_Menu ld hl,_OP1 ld de,CurName call _mov10b rst 10h ld a,b ex de,hl call _load_ram_ahl inc hl inc hl ld de,$FC00 ld bc,1008 ldir ld b,62 ld c,31 call CursInv jp Draw_GetLoop Make_A_New_Pic: call _clrScrn call _homeup ld hl,Create_New_Str set 3,(iy+5) call _puts res 3,(iy+5) call Get_A_New_Name ld hl,_OP1 ld de,Cur_Temp_Name call _mov10b jp z,Main_Menu rst 10h call c,_CREATEPICT ld hl,_OP1 ld a,(hl) cp $11 call nz,Exists_But_Not_Pic cp 0 jp z,Main_Menu ld hl,Cur_Temp_Name ld de,CurName call _mov10b ld hl,CurName ld de,_OP1 call _mov10b call _clrScrn ld b,62 ld c,31 call CursInv jp Save_Pic ;******************************Main Loop**************************** Clear_The_Screen: call _clrScrn Edit_A_Pic: ld b,62 ld c,31 call CursInv Draw_GetLoop: ld (Pos),bc ;dont ruin the coords call _getky ld bc,(Pos) ;put em back cp K_F1 jp z,Main_Menu ;go back to main menu cp K_EXIT jr z,Exit_The_Program ;Leave the prog cp K_CLEAR jr z,Clear_The_Screen ;clear the screen cp K_F3 jp z,Save_Pic_As ;save the current screen with new name cp K_LEFT jp z,Move_Left ;move cursor 1 pxl left cp K_RIGHT jp z,Move_Right ;move cursor 1 pxl right cp K_UP jp z,Move_Up ;Move cursor 1 pxl up cp K_DOWN jp z,Move_Down ;move cursor 1 pxl down cp K_F2 jp z,Save_Pic ;save the pic to the current name cp K_SECOND jp z,Set_Pixel ;set curent pixel to dark cp K_ALPHA jp z,Reset_Pixel ;set to white cp K_GRAPH jp z,Toggle_Pixel ;reverse pixel cp K_7 jp z,Top_Right ;move cursor to this place 1-9 cp K_8 jp z,Top_Middle cp K_9 jp z,Top_Left cp K_4 jp z,Middle_Left cp K_5 jp z,Middle_Middle cp K_6 jp z,Middle_Right cp K_1 jp z,Bottom_Left cp K_2 jp z,Bottom_Middle cp K_3 jp z,Bottom_Right cp K_LOG jp z,Invert_Screen jp Draw_GetLoop Exit_The_Program: ;time to leave call _clrScrn ;clear the screen call _homeup ;reset the currow and curcol ret Set_Pixel: ;set curent pxl to dark call CursInv call PixelOn call CursInv jp Draw_GetLoop Reset_Pixel: ;reset pxl (white) call CursInv call PixelOff call CursInv jp Draw_GetLoop Toggle_Pixel: ;reverse pixel call CursInv call PixelInv call CursInv jp Draw_GetLoop Top_Right: call CursInv ld b,1 ld c,1 call CursInv jp Draw_GetLoop Top_Middle: call CursInv ld b,62 ld c,1 call CursInv jp Draw_GetLoop Top_Left: call CursInv ld b,126 ld c,1 call CursInv jp Draw_GetLoop Middle_Left: call CursInv ld b,1 ld c,31 call CursInv jp Draw_GetLoop Middle_Middle: call CursInv ld b,62 ld c,31 call CursInv jp Draw_GetLoop Middle_Right: call CursInv ld b,126 ld c,31 call CursInv jp Draw_GetLoop Bottom_Left: call CursInv ld b,1 ld c,62 call CursInv jp Draw_GetLoop Bottom_Middle: call CursInv ld b,62 ld c,62 call CursInv jp Draw_GetLoop Bottom_Right: call CursInv ld b,126 ld c,62 call CursInv jp Draw_GetLoop Invert_Screen: call CursInv ld (Pos),bc ld hl,$FC00 ld bc,1008 Invert_Looper: ld a,(hl) cpl ld (hl),a inc hl dec bc ld a,b or c jr nz,Invert_Looper ld bc,(Pos) call CursInv jp Draw_GetLoop Save_Pic: ;save the pic ld (Pos),bc ;save bc call CursInv ;take out the cursor ld hl,CurName ;this is the current pic name rst 20h ;move the name to op1 rst 10h ;find the address ld a,b ;bde->ahl ex de,hl call _load_ram_ahl ;load ram page and hl=address ex de,hl ;de = address inc de ;inc past the size inc de ;pointers ld hl,$FC00 ;place to move from ld bc,1008 ;how much to move ldir ;move it ld bc,(Pos) ;reset bc to cursor position call CursInv ;display the cursor jp Draw_GetLoop ;return to the getkey loop Save_Pic_As: call CursInv ;take cursor off screen ld (Pos),bc ;save the position ld hl,_OP1 ;save the current pic name ld de,CurName call _mov10b ld hl,$FC00 ;back up the screen ld de,_plotSScreen ld bc,1008 ldir call _clrScrn ;clear the main screen call _homeup ;reset currow, curcol ld hl,Save_As_Str set 3,(iy+5) call _puts res 3,(iy+5) call Get_A_New_Name ;routine for entering a name jp z,Skip_Save_Name ;if they exited, dont save the name Save_Name: ld hl,_OP1 ;save the new name(from input routine) ld de,Cur_Temp_Name ;into a temp place call _mov10b rst 10h ;get its address call c,_CREATEPICT ;if it doesnt exist make a new pic ld hl,_OP1 ;get the type byte in OP1 ld a,(hl) ;if it is 11, its a pic cp $11 ;if not its some other var type call nz,Exists_But_Not_Pic ;so go here cp 0 ;see of a is zero jr z,Skip_Save_Name ;if it is, then the name wasn't a pic ld hl,Cur_Temp_Name ;Set temp curname to curname ld de,CurName call _mov10b ld hl,CurName ;and move it to OP1 also ld de,_OP1 call _mov10b ld hl,_plotSScreen ;and redo the screen ld de,$FC00 ld bc,1008 ldir ld bc,(Pos) ;redo the cursor position call CursInv ;redo the cursor jp Save_Pic Skip_Save_Name: ;this is for when you enter an invalid name ld hl,CurName ;put the old curname back into op1 ld de,_OP1 call _mov10b ld hl,_plotSScreen ;redo the screen ld de,$FC00 ld bc,1008 ldir ld bc,(Pos) ;redo the cursor position call CursInv ;and the curso too jp Draw_GetLoop Exists_But_Not_Pic: ;this is for when the var isn't a pic res 2,(iy+13) ;dont scroll the screen call _clrScrn ;clear the screen call _homeup ;reset the coords ld hl,Error_Msg1 ;an error message call _puts ;print it ld hl,$1107 ;new coords ld (_curRow),hl ;save them to the right address ld hl,Quit_Msg ;load the message call _puts ;print it set 2,(iy+13) ;reset to scrolling screen Error1_GetLoop: call _getkey ;wait for f5 cp kF5 jr nz,Error1_GetLoop xor a ;set a to 0 (when it returns, the other routine will check for it ret ;return Move_Left: call CursInv ;move the cursor left dec b call Check_Wall_Left call CursInv jp Draw_GetLoop Move_Right: call CursInv ;move the cursor right inc b call Check_Wall_Right call CursInv jp Draw_GetLoop Move_Up: call CursInv ;move the cursor down dec c call Check_Wall_Up call CursInv jp Draw_GetLoop Move_Down: call CursInv inc c ;move the cursor up call Check_Wall_Down call CursInv jp Draw_GetLoop Check_Wall_Right: ld a,127 ;make sure it isnt off the screen cp b ret nz dec b ret Check_Wall_Left: ld a,0 cp b ;same ret nz inc b ret Check_Wall_Up: ld a,0 cp c ret nz ;and again inc c ret Check_Wall_Down: ld a,63 cp c ;one more time ret nz dec c ret CursInv: call PixelInv dec b ;draw the cursor dec c call PixelInv inc b inc b call PixelInv inc c inc c call PixelInv dec b dec b call PixelInv inc b dec c ret PixelOn: call Find_Pixel ;set a pixel at b,c or (hl) ld (hl),a ret PixelOff: call Find_Pixel ;reset a pixel at b,c cpl and (hl) ld (hl),a ret PixelInv: call Find_Pixel ;Invert a pixel at b,c xor (hl) ld (hl),a ret Find_Pixel: ;clem's find pixel routine push bc ld h,63 ld a,c add a,a add a,a ld l,a ld a,b rra add hl,hl rra add hl,hl rra or l ld l,a ld a,b and 7 ld bc,FP_Bits add a,c ld c,a adc a,b sub c ld b,a ld a,(bc) pop bc ret ;***********************Load Routine********************** Load_A_Pic_Name: ld hl,Load_Pic_Str set 3,(iy+5) call _puts res 3,(iy+5) ld hl,$0002 ld (_curRow),hl ld hl,Pic_Str ;load a message call _puts ;print to screen ld hl,First_Pic ;lload a pic name rst 20h ;move to op1 xor a ;clear a call $514B ;find next matching var jp c,Exit_The_Load_Routine ;if there isnt one, return ld hl,First_Pic ;else put it back rst 20h ;into op1 Find_The_Next_Pic: xor a call $514B jr c,Get_Loader_Key jr Display_Pic_Name Find_The_Last_Pic: xor a call $514F jr c,Get_Loader_Key Display_Pic_Name: ld hl,$0A02 ld (_curRow),hl ld hl,_OP1+2 call _puts ld hl,Spaces call _puts Get_Loader_Key: call _getky cp K_EXIT jp z,Exit_The_Load_Routine cp K_LEFT jp z,Find_The_Last_Pic cp K_RIGHT jp z,Find_The_Next_Pic cp K_ENTER jp z,Load_This_Pic cp K_SECOND jp z,Load_This_Pic jr Get_Loader_Key Load_This_Pic: ld a,1 cp 2 ret Exit_The_Load_Routine: cp a ret ;---------------------New Pic Routine------------------------ Get_A_New_Name: ld hl,$0002 ld (_curRow),hl ld hl,Pic_Name_Msg call _puts ld hl,$0A02 ld (_curRow),hl ld hl,_OP1+2 push hl ld b,10 Clear_Loop: ld (hl),$00 inc hl djnz Clear_Loop pop ix ld b,0 Enter_Your_Name: push bc call _getky pop bc or a jr z,Enter_Your_Name cp K_DEL jr z,Backup cp K_EXIT jp z,Exit_No_Save cp K_SECOND jr z,NoMore sub 9 jr z,NoMore dec a bit 7,a jr c,Enter_Your_Name ld hl,chartable ld e,a ld d,0 add hl,de ld a,8 cp b jp z,Put_End_Char ld a,(hl) or a jr z,Enter_Your_Name ld (ix),a call _putc ld a,$E1 call _putc push hl ld hl,_curCol dec (hl) pop hl inc b inc ix ld a,$08 cp b jr z,Put_End_Char jr Enter_Your_Name Backup: xor a cp b jr z,Enter_Your_Name ld a,$08 cp b call z,Del_End_Char ld a,$20 call _putc ld hl,_curCol dec (hl) dec b dec ix ld a,$00 ld (ix),a ld a,$E1 ld hl,_curCol dec (hl) call _putc dec (hl) jr Enter_Your_Name Put_End_Char: ld hl,$1202 ld (_curRow),hl ld a,$E7 call _putc jp Enter_Your_Name Del_End_Char: ld hl,_curCol dec (hl) ret Exit_No_Save: cp a ret NoMore: ld hl,_OP1 ld (hl),$11 inc hl ld (hl),b ld a,1 cp 2 ret ;****************************Text and Vars************************ FP_Bits: .db $80,$40,$20,$10,$08,$04,$02,$01 Pic_Name_Msg: .db "Pic Name: ",$E1,0 chartable: .db "XTOJE",0,0,0,"WSNID",'9',0,"ZVRMHC",'8' .db 0,"YUQLGB",'7',0,0,0,"PKFA",'6',0,"54321",0,0,0 First_Pic: .db $11,$00 Pic_Str: .db "Pic Name: ",0 Spaces: .db " ",0 Save_As_Str: .db " Save Picture As ",0 Create_New_Str: .db " New Picture ",0 Load_Pic_Str: .db " Load Picture ",0 Title_Str: .db "Sketch Pad v.1",0 Title_Str1: .db " Sketch Pad v.1 ",0 Title_Str2: .db " by Chicane ",0 Error_Msg1: .db "ERROR 17 INVALID",0 Quit_Msg: .db "Quit",0 Menu_Str: .db " New " .db "Load " .db " Keys " .db " " .db " Exit",0 Help_Keys: .db " Drawing Screen ",0 Help_Keys_Sub1: .db $06," = Up ",$07," = Down ",$CF," = Left ",$05," = Right ",0 Help_Keys_Sub2: .db "F1 = Main F2 = Save F3 = Save As",0 Help_Keys_Sub3: .db "2nd = On Alpha = Off Graph = Change",0 Help_Keys_Sub4: .db "1-9 = Move to that part of the screen",0 CurName: .db " ",0 Cur_Temp_Name: .db " ",0 Pos: .dw 0000 .end