home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 83 / asm / source / skiedit.z80 < prev    next >
Encoding:
Text File  |  2001-07-01  |  27.1 KB  |  937 lines

  1. .NOLIST
  2. #define equ .equ
  3. #define EQU .equ
  4. #define end .end
  5. #include "ti83asm.inc"
  6. #include "tokens.inc"
  7. .LIST
  8.  
  9. #define temp 8265h                ; temporary
  10. #define levelname 8266h           ; name of current level
  11. #define level 826Ah               ; pointer to symbol table entry of current level
  12. #define row 826Ch                 ; level offset row
  13. #define col 826Eh                 ; level offset col
  14. #define itemnum 826Fh             ; current item (while editing)
  15.  
  16. _createprog .equ 448Ah            ; create new program (name in op1)
  17. _memfree .equ 441Ah               ; free memory into hl
  18. lcddata .equ 11h                  ; lcd data port
  19.  
  20. progobj .equ 05h                  ; program
  21. protprogobj .equ 06h              ; protected program
  22. listobj .equ 01h                  ; list
  23. clistobj .equ 0Dh                 ; complex list
  24.  
  25. .org 9327h
  26.  
  27.      call _runindicoff
  28.  
  29. ; main screen select your option: new or edit
  30. ;
  31. ;  up - changes selection
  32. ;  down - changes selection
  33. ;  2nd - selects
  34. ;  clear - quits program
  35.  
  36. titlescreen:
  37.  
  38.      call _grbufclr               ; clear buffer
  39.      ld hl,title                  ; draw title
  40.      ld de,plotsscreen+60         ;
  41.      ld bc,300                    ;
  42.      ldir                         ;
  43.      set textwrite,(iy+sgrflags)  ; write to buffer
  44.      ld hl,$221D                  ; write "Level Editor"
  45.      ld (pencol),hl               ;
  46.      ld hl,editor                 ;
  47.      call _vputs                  ;
  48.      ld hl,$2D2A                  ; write "New"
  49.      ld (pencol),hl               ;
  50.      ld hl,newstr                 ;
  51.      call _vputs                  ;
  52.      ld hl,$342A                  ; write "Edit"
  53.      ld (pencol),hl               ;
  54.      ld hl,editstr                ;
  55.      call _vputs                  ;
  56.      res textwrite,(iy+sgrflags)  ; write to display
  57.      ld hl,plotsscreen+544        ; invert menu item
  58.      call invert_area             ;
  59.      call bufcpy                  ; copy buffer to screen
  60.      ld a,0                       ; temp holds selected menu item
  61.      ld (temp),a                  ;
  62.  
  63. title_loop:
  64.  
  65.      call _getk
  66.      ld a,21                      ; was 2nd pressed
  67.      call _setxxop1               ;
  68.      call _cpop1op2               ;
  69.      jp z,start                   ; make a new level
  70.      ld a,25                      ; was up pressed
  71.      call _setxxop1               ;
  72.      call _cpop1op2               ;
  73.      call z,change                ; make a new level
  74.      ld a,34                      ; was down pressed
  75.      call _setxxop1               ;
  76.      call _cpop1op2               ;
  77.      call z,change                ; select a level to edit
  78.      ld a,45                      ; was Clear pressed
  79.      call _setxxop1               ;
  80.      call _cpop1op2               ;
  81.      ret z                        ; quit
  82.      jr title_loop
  83.  
  84. change:
  85.  
  86.      ld a,(temp)                  ; change selected menu item
  87.      cpl                          ;
  88.      ld (temp),a                  ;
  89.      ld hl,plotsscreen+544        ;
  90.      call invert_area             ;
  91.      ld hl,plotsscreen+628        ;
  92.      call invert_area             ;
  93.      call bufcpy                  ;
  94.      ret
  95.  
  96. start:
  97.  
  98.      ld a,(temp)                  ; if temp is zero create new
  99.      cp 0                         ;
  100.      jr z,new                     ;
  101.      jp getlevel                  ; if temp is not zero edit
  102.  
  103. ; screen for creating a new level
  104. ;
  105. ;  2nd - selects initial
  106. ;  up arrow - moves initial up
  107. ;  down arrow - moves initial down
  108.  
  109. new:
  110.  
  111.      call clearbottom             ; clear bottom of screen
  112.      call bufcpy                  ; copy buffer to screen
  113.      call _memfree                ; see if there is enough mem for a new level
  114.      ld de,1558                   ;
  115.      call _cphlde                 ;
  116.      jp c,nomem                   ;
  117.      ld hl,$2D21                  ; write out "Name:"
  118.      ld (pencol),hl               ;
  119.      ld hl,namestr                ;
  120.      call _vputs                  ;
  121.      ld a,$36                     ; position cursor
  122.      ld (pencol),a                ;
  123.      call getinitial              ; get 1st initial
  124.      ld (levelname),a             ; store initial
  125.      ld a,$3A                     ; position cursor
  126.      ld (pencol),a                ;
  127.      call getinitial              ; get 2nd initial
  128.      ld (levelname+1),a           ; store initial
  129.      ld a,$3E                     ; position cursor
  130.      ld (pencol),a                ;
  131.      call getinitial              ; get 3rd initial
  132.      ld (levelname+2),a           ; store initial
  133.      ld hl,defaultprog            ; copy progobj and 1st 5 chars to op1
  134.      ld de,op1                    ;
  135.      ld bc,6                      ;
  136.      ldir                         ;
  137.      ld hl,levelname              ; append level name to op1
  138.      ld bc,3                      ;
  139.      ldir                         ;
  140.      call _chkfindsym             ; look up new prog
  141.      call nc,_delvar              ; if it is already created delete it
  142.      ld hl,1544                   ; size 1530 bytes
  143.      call _createprog             ; create it
  144.      ld (hl),protprogobj          ; make it protected
  145.      inc de                       ; skip 1st length byte
  146.      inc de                       ; skip 2nd length byte
  147.      ld bc,1544                   ; length
  148.  
  149. clearloop:
  150.  
  151.      ld a,0                       ; fill level with zeros
  152.      ld (de),a                    ;
  153.      inc de                       ;
  154.      dec bc                       ;
  155.      ld a,b                       ;
  156.      or c                         ;
  157.      jr nz,clearloop              ;
  158.      dec hl
  159.      dec hl
  160.      dec hl
  161.      push hl
  162.      jp edit
  163.  
  164. nomem:
  165.  
  166.      ld hl,$2D11                  ; write "Not Enough Memory"
  167.      ld (pencol),hl               ;
  168.      ld hl,nomemstr               ;
  169.      call _vputs                  ;
  170.      call waitforkey              ; wait for key press
  171.      jp titlescreen               ; return to menu
  172.  
  173. ; screen for choosing an already created level to edit
  174. ;
  175. ;  2nd - selects level
  176. ;  Alpha - changes level
  177.  
  178. getlevel:
  179.  
  180.      ld a,0                       ; temp holds the number of levels
  181.      ld (temp),a                  ; if temp is 0 at the end there aren't any levels
  182.      ld hl,(progptr)              ; start of program/list symbol table
  183.  
  184. level_loop:
  185.  
  186.      ld a,(hl)                    ; get object type
  187.      and $1F                      ; mask off bits 0-4
  188.      cp progobj                   ; is it a program?
  189.      jr z,program                 ;
  190.      cp protprogobj               ; is it a protected program?
  191.      jr z,program                 ;
  192.      cp listobj                   ; is it a list?
  193.      jp z,list                    ;
  194.      cp clistobj                  ; is it a complex list?
  195.      jp z,list                    ;
  196.      ld a,(temp)                  ; see if count is zero
  197.      cp 0                         ;
  198.      jr nz,getlevel               ; end of program/list symbol table. start over
  199.      call clearbottom             ; clear bottom of screen
  200.      set textwrite,(iy+sgrflags)  ; write to plotsscreen
  201.      ld hl,$2D16                  ; write "There arent any"
  202.      ld (pencol),hl               ;
  203.      ld hl,nolevel1               ;
  204.      call _vputs                  ;
  205.      ld hl,$341B                  ; write "levels to edit"
  206.      ld (pencol),hl               ;
  207.      ld hl,nolevel2               ;
  208.      call _vputs                  ;
  209.      res textwrite,(iy+sgrflags)  ; write to display
  210.      call bufcpy                  ; copy buffer to screen
  211.      call waitforkey              ; wait for key press
  212.      jp titlescreen               ; return to title screen
  213.  
  214. program:
  215.  
  216.      dec hl                       ; skip T
  217.      dec hl                       ; skip DAL
  218.      dec hl                       ; skip DAH
  219.      ld b,(hl)                    ; get length of name
  220.      ld a,b                       ;
  221.      cp 8                         ; is the name 8 chars long?
  222.      jr z,good_prog               ; if it is then it could be a valid level
  223.  
  224. program_loop:
  225.  
  226.      dec hl                       ; get past name
  227.      djnz program_loop            ; 
  228.      dec hl                       ; next pointer
  229.      jr level_loop                ;
  230.  
  231. good_prog:
  232.  
  233.      push hl                      ; save program address
  234.      ld b,5                       ; five chars to test
  235.      ld de,defaultprog+1          ; name to test against
  236.  
  237. cploop:                           ; compare name to base name
  238.  
  239.      dec hl                       ; next char
  240.      ld a,(de)                    ;
  241.      cp (hl)                      ; are they the same?
  242.      jp nz,nextprog               ; if not move on to the next program
  243.      inc de                       ; next char
  244.      djnz cploop                  ;
  245.      ld de,levelname              ;
  246.      ld b,3                       ;
  247.  
  248. cpyloop:
  249.  
  250.      dec hl                       ; copy last 3 chars of name
  251.      ld a,(hl)                    ;
  252.      ld (de),a                    ;
  253.      inc de                       ;
  254.      djnz cpyloop                 ;
  255.      ld a,0                       ; add 0 terminator
  256.      ld (de),a                    ;
  257.      ld a,(temp)                  ; increment count
  258.      inc a                        ;
  259.      ld (temp),a                  ;
  260.      call clearbottom             ; clear bottom of screen
  261.      set textwrite,(iy+sgrflags)  ; write to plotsscreen
  262.      ld hl,$2D23                  ; write "Edit:"
  263.      ld (pencol),hl               ;
  264.      ld hl,selectstr              ;
  265.      call _vputs                  ;
  266.      ld hl,$2D33                  ; write level name
  267.      ld (pencol),hl               ;
  268.      ld hl,levelname              ;
  269.      call _vputs                  ;
  270.      res textwrite,(iy+sgrflags)  ; write to display
  271.      call bufcpy
  272.  
  273. key_loop:
  274.  
  275.      call _getk
  276.      ld a,21                      ; was 2nd pressed
  277.      call _setxxop1               ;
  278.      call _cpop1op2               ;
  279.      jp z,edit                    ; start editing
  280.      ld a,31                      ; was Alpha pressed
  281.      call _setxxop1               ;
  282.      call _cpop1op2               ;
  283.      jp z,nextprog                ; next level
  284.      jr key_loop                  ;
  285.  
  286. nextprog:
  287.  
  288.      pop hl                       ; restore program address
  289.      ld b,8                       ; 8 chars in name
  290.      jp program_loop              ; next pointer
  291.  
  292. list:
  293.  
  294.      dec hl                       ; skip T
  295.      dec hl                       ; skip DAL
  296.      dec hl                       ; skip DAH
  297.      ld b,(hl)                    ; get length
  298.  
  299. list_loop:
  300.  
  301.      dec hl                       ; skip over name
  302.      djnz list_loop               ; 
  303.      dec hl                       ; next pointer
  304.      jp level_loop                ;
  305.  
  306. ; once you have selected or created your level you can begin editing
  307. ; hl should point to the program/list symbol table entry of the level
  308. ;
  309. ;  2nd - places item
  310. ;  arrows - move item
  311. ;  alpha - changes item
  312. ;  clear - returns to title screen
  313.  
  314. edit:
  315.  
  316.      pop hl                       ; restore address to level
  317.      inc hl                       ; move to DAL
  318.      ld d,(hl)                    ; copy data address to de
  319.      inc hl                       ; set high score to 0
  320.      ld e,(hl)                    ;
  321.      ld hl,2                      ;
  322.      add hl,de                    ;
  323.      ld (hl),0                    ;
  324.      inc hl                       ;
  325.      ld (hl),0                    ;
  326.      inc hl                       ;
  327.      ld (level),hl                ; store address to current level data
  328.      ld (row),hl                  ; current level offset
  329.      ld a,5                       ; current row offset
  330.      ld (col),a                   ;
  331.      ld a,1                       ; current item number
  332.      ld (itemnum),a               ;
  333.      call _grbufclr               ; clear buffer
  334.      call redraw                  ; draw out level
  335.      call bufcpy                  ;
  336.  
  337. edit_key_loop:
  338.  
  339.      call _getk
  340.      ld a,25                      ; was up pressed
  341.      call _setxxop1               ;
  342.      call _cpop1op2               ;
  343.      jp z,editup                  ; move item up
  344.      ld a,34                      ; was down pressed
  345.      call _setxxop1               ;
  346.      call _cpop1op2               ;
  347.      jp z,editdown                ; move item down
  348.      ld a,24                      ; was left pressed
  349.      call _setxxop1               ;
  350.      call _cpop1op2               ;
  351.      jp z,editleft                ; move item right
  352.      ld a,26                      ; was right pressed
  353.      call _setxxop1               ;
  354.      call _cpop1op2               ;
  355.      jp z,editright               ; move item left
  356.      ld a,21                      ; was 2nd pressed
  357.      call _setxxop1               ;
  358.      call _cpop1op2               ;
  359.      jp z,putitem                 ; put item at current position
  360.      ld a,31                      ; was Alpha pressed
  361.      call _setxxop1               ;
  362.      call _cpop1op2               ;
  363.      jp z,changeitem              ; toggle item
  364.      ld a,45                      ; was clear pressed
  365.      call _setxxop1               ;
  366.      call _cpop1op2               ;
  367.      jp z,titlescreen             ; quit
  368.      jp edit_key_loop
  369.  
  370. editup:
  371.  
  372.      ld hl,(row)                  ; are we at the top of the level
  373.      ld de,(level)                ;
  374.      call _cphlde                 ;
  375.      jp z,edit_key_loop           ; return to key loop
  376.      ld de,6                      ; move to the next row
  377.      sbc hl,de                    ;
  378.      ld (row),hl                  ;
  379.      call redraw                  ; draw out level
  380.      jp edit_key_loop             ; return to key loop
  381.  
  382. editdown:
  383.  
  384.      ld hl,(level)                ; are we at the bottom of the level
  385.      ld de,1488                   ;
  386.      add hl,de                    ;
  387.      ex de,hl                     ;
  388.      ld hl,(row)                  ;
  389.      call _cphlde                 ;
  390.      jp z,edit_key_loop           ; return to key loop
  391.      ld de,6                      ; move to previous row
  392.      add hl,de                    ;
  393.      ld (row),hl                  ;
  394.      call redraw                  ; draw out level
  395.      jp edit_key_loop             ; return to key loop
  396.  
  397. editleft:
  398.  
  399.      ld a,(col)                   ; are we at the very left
  400.      cp 0                         ;
  401.      jp z,edit_key_loop           ; return to key loop
  402.      dec a                        ; move to next col
  403.      ld (col),a                   ;
  404.      call redraw                  ; draw out level
  405.      jp edit_key_loop             ; return to key loop
  406.  
  407. editright:
  408.  
  409.      ld a,(col)                   ; are we at the very right
  410.      cp 11                        ;
  411.      jp z,edit_key_loop           ; return to key loop
  412.      inc a                        ; move to next col
  413.      ld (col),a                   ;
  414.      call redraw                  ; draw out level
  415.      jp edit_key_loop             ; return to key loop
  416.  
  417. putitem:
  418.  
  419.      ld a,(col)                   ; get col offset
  420.      bit 0,a                      ; 0 means it is even
  421.      jr nz,odd                    ; 1 means it is odd
  422.  
  423. even:
  424.  
  425.      srl a                        ; divide col offset by 2
  426.      ld d,0                       ; add it to the row offset
  427.      ld e,a                       ;
  428.      ld hl,(row)                  ;
  429.      add hl,de                    ;
  430.      ld a,(hl)                    ; get item
  431.      and $0F                      ; mask off item
  432.      ld (hl),a                    ;
  433.      ld a,(itemnum)               ;
  434.      sla a                        ; shift to the left 4 times
  435.      sla a                        ;
  436.      sla a                        ;
  437.      sla a                        ;
  438.      or (hl)                      ;
  439.      ld (hl),a                    ; write item
  440.      jp edit_key_loop             ; return to key loop
  441.  
  442. odd:
  443.  
  444.      srl a                        ; divide col offset by 2
  445.      ld d,0                       ; add it to the row offset
  446.      ld e,a                       ;
  447.      ld hl,(row)                  ;
  448.      add hl,de                    ;
  449.      ld a,(hl)                    ; get item
  450.      and $F0                      ; mask off item
  451.      ld (hl),a                    ;
  452.      ld a,(itemnum)               ;
  453.      or (hl)                      ;
  454.      ld (hl),a                    ; write item
  455.      jp edit_key_loop             ; return to key loop
  456.  
  457. changeitem:
  458.  
  459.      ld a,(itemnum)               ; are we at the last item
  460.      cp 5                         ;
  461.      jr z,nomore                  ;
  462.      ld a,(itemnum)               ; inc item num
  463.      inc a                        ;
  464.      ld (itemnum),a               ;
  465.      call redraw                  ; redraw level
  466.      jp edit_key_loop             ; return to key loop
  467.  
  468. nomore:
  469.  
  470.      ld a,0                       ; set itemnum to 0
  471.      ld (itemnum),a               ;
  472.      call redraw                  ; redraw level
  473.      jp edit_key_loop             ; return to key loop
  474.  
  475. ; draws out level compared to current offset
  476.  
  477. redraw:
  478.  
  479.      call _grbufclr               ; clear buffer
  480.      ld hl,(row)                  ; start at current level offset
  481.      ld de,plotsscreen            ; copy to buffer
  482.      ld b,8                       ; 8 rows
  483.  
  484. draw_loop1:
  485.  
  486.      push bc
  487.      ld b,6                       ; 6 bytes per row
  488.  
  489. draw_loop2:
  490.  
  491.      push bc
  492.      ld a,(hl)                    ; get data
  493.      push hl                      ; save address to current level byte
  494.      srl a                        ; shift right 4
  495.      srl a                        ;
  496.      srl a                        ;
  497.      srl a                        ;
  498.      call cpitem                  ; draw item
  499.      inc de                       ; move to next byte in buffer
  500.      pop hl                       ; restore address to current level byte
  501.      ld a,(hl)                    ; get data
  502.      push hl                      ; save address to current level byte
  503.      and $0F                      ; mask off first 4 bits
  504.      call cpitem                  ; draw item
  505.      inc de                       ; move to next byte in buffer
  506.      pop hl                       ; restore address to current level byte
  507.      inc hl                       ; move to next byte in level
  508.      pop bc
  509.      djnz draw_loop2
  510.  
  511. next_row:
  512.  
  513.      push hl
  514.      ld hl,84                     ; move to next row down in plotsscreen
  515.      add hl,de                    ;
  516.      ex de,hl                     ;
  517.      pop hl                       ;
  518.      pop bc                       ;
  519.      djnz draw_loop1              ;
  520.      ld de,plotsscreen            ; move to col offset in buffer
  521.      ld h,0                       ;
  522.      ld a,(col)                   ;
  523.      ld l,a                       ;
  524.      add hl,de                    ;
  525.      ex de,hl                     ;
  526.      ld a,(itemnum)               ; get item
  527.      call cpitem                  ; draw item
  528.      call bufcpy                  ; copy buffer to screen
  529.      ret
  530.  
  531. cpitem:
  532.  
  533.      cp 0                         ; is it a blank
  534.      call z,drawblank             ;
  535.      cp 1                         ; is it grass
  536.      call z,drawgrass             ;
  537.      cp 2                         ; is it a tree
  538.      call z,drawtree              ;
  539.      cp 3                         ; is it a small rock
  540.      call z,drawrock1             ;
  541.      cp 4                         ; is it a large rock
  542.      call z,drawrock2             ;
  543.      cp 5                         ; is it a gate
  544.      call z,drawgate              ;
  545.      ret
  546.  
  547. ; draws out item
  548.  
  549. draw_item:
  550.  
  551.      push de                      ; save current address in plotsscreen
  552.      ld b,8
  553.  
  554. draw_item_loop:
  555.  
  556.      push bc
  557.      push hl
  558.      ld a,(hl)
  559.      ld (de),a
  560.      ld hl,12
  561.      add hl,de
  562.      ex de,hl
  563.      pop hl
  564.      inc hl
  565.      pop bc
  566.      djnz draw_item_loop
  567.      pop de                       ; restore current address in plotsscreen
  568.      ret
  569.  
  570. ; sets up drawing for each item
  571.  
  572. drawblank:
  573.  
  574.      ld hl,blank
  575.      call draw_item
  576.      ret
  577.  
  578. drawgrass:
  579.  
  580.      ld hl,grass
  581.      call draw_item
  582.      ret
  583.  
  584. drawtree:
  585.  
  586.      ld hl,tree
  587.      call draw_item
  588.      ret
  589.  
  590. drawrock1:
  591.  
  592.      ld hl,rock1
  593.      call draw_item
  594.      ret
  595.  
  596. drawrock2:
  597.  
  598.      ld hl,rock2
  599.      call draw_item
  600.      ret
  601.  
  602. drawgate:
  603.  
  604.      ld hl,gate
  605.      call draw_item
  606.      ret
  607.  
  608. ; get 1 initial from user, draw it to the current cursor location,
  609. ; and store the letter in the accumulator
  610.  
  611. getinitial:
  612.  
  613.      ld hl,chars                  ; start of my own character map
  614.      call drawchar                ; draw out the starting char
  615.      push hl                      ; save offset in char map
  616.  
  617. iniloop:
  618.  
  619.      call _getk
  620.      ld a,25                      ; was up pressed
  621.      call _setxxop1               ;
  622.      call _cpop1op2               ;
  623.      jr z,iniup                   ; move to next initial
  624.      ld a,34                      ; was down pressed
  625.      call _setxxop1               ;
  626.      call _cpop1op2               ;
  627.      jr z,inidown                 ; move to previous initial
  628.      ld a,21                      ; was 2nd pressed
  629.      call _setxxop1               ;
  630.      call _cpop1op2               ;
  631.      jr z,inidone                 ;
  632.      jr iniloop
  633.  
  634. iniup:
  635.  
  636.      pop hl                       ; get offset in char map
  637.      ld a,(hl)                    ; are we at the last char?
  638.      cp '9'                       ;
  639.      jr z,noup                    ;
  640.      inc hl                       ; move to next char
  641.      call drawchar                ; draw the char
  642.      push hl                      ; save offset
  643.      jr iniloop
  644.  
  645. inidown:
  646.  
  647.      pop hl                       ; restore offset
  648.      ld a,(hl)                    ; are we at the first char?
  649.      cp 'A'                       ;
  650.      jr z,nodown                  ;
  651.      dec hl                       ; move to previous char
  652.      call drawchar                ; draw the char
  653.      push hl                      ; save offset
  654.      jr iniloop
  655.  
  656. noup:
  657.  
  658.      ld hl,chars                  ; loop back to the start of the char map
  659.      call drawchar                ; draw the char
  660.      push hl                      ; save offset
  661.      jr iniloop
  662.  
  663. nodown:
  664.  
  665.      ld hl,chars+35               ; loop back to the end of the char map
  666.      call drawchar                ; draw the char
  667.      push hl                      ; save offset
  668.      jr iniloop
  669.  
  670. inidone:
  671.  
  672.      pop hl                       ; get rid of the offset
  673.      ld a,(hl)                    ; save selected char in a
  674.      ret
  675.  
  676. drawchar:
  677.  
  678.      ld a,(hl)                    ; get the char
  679.      call _vputmap                ; draw it
  680.      ld a,(pencol)                ; get pencol
  681.      sub 4                        ; set it back to normal
  682.      ld (pencol),a                ; put it in pencol
  683.      ret
  684.  
  685. ; waits for any key yo be pressed
  686.  
  687. waitforkey:
  688.  
  689.      call _getk                   ; wait for any key press
  690.      ld a,0                       ;
  691.      call _setxxop1               ;
  692.      call _cpop1op2               ;
  693.      jr z,waitforkey              ;
  694.      ret                          ; return
  695.  
  696. ; inverts 16x7 area at hl
  697.  
  698. invert_area:
  699.  
  700.      push hl
  701.      ld b,7
  702.  
  703. invert_loop:
  704.  
  705.      push bc
  706.      push hl
  707.      ld b,4
  708.  
  709. invert_loop2:
  710.  
  711.      ld a,(hl)
  712.      cpl
  713.      ld (hl),a
  714.      inc hl
  715.      djnz invert_loop2
  716.      pop hl
  717.      pop bc
  718.      ld de,12
  719.      add hl,de
  720.      djnz invert_loop
  721.      pop hl
  722.      ret
  723.  
  724. clearbottom:
  725.  
  726.      ld hl,plotsscreen+528
  727.      ld de,plotsscreen+708
  728.  
  729. clear_loop:
  730.  
  731.      ld (hl),0
  732.      inc hl
  733.      call _cphlde
  734.      jr nz,clear_loop
  735.      ret
  736.  
  737. ; copy plotsscreen to lcd
  738. ; faster than _grbufcpy_v
  739.  
  740. bufcpy:
  741.  
  742.      ld hl,plotsscreen
  743.      ld b,40h
  744.      di
  745.      ld a,7
  746.      call LCDBusy
  747.      out (lcdinstport),a
  748.      ld a,127
  749.  
  750. bclcpy:
  751.  
  752.      push bc
  753.      inc a
  754.      ld (8012h),a
  755.      call s7port10
  756.      call lcdbusy
  757.      out (lcdinstport),a
  758.  
  759.      ld a,20h
  760.      call lcdbusy
  761.      out (lcdinstport),a
  762.      ld b,12
  763.  
  764. bcl2cpy:
  765.  
  766.      ld a,(hl)
  767.      inc hl
  768.      call lcdbusy
  769.      out (lcddata),a
  770.      djnz bcl2cpy
  771.      pop bc
  772.      ld a,(8012h)
  773.      djnz bclcpy
  774.      ld a,5
  775.      call lcdbusy
  776.      out (lcdinstport),a
  777.      ei
  778.      ret
  779.  
  780. lcdbusy:
  781.  
  782.      push af
  783.      inc hl
  784.      dec hl
  785.      pop af
  786.      ret
  787.  
  788. s7port10:
  789.  
  790.      push af
  791.      ld a,7
  792.      call lcdbusy
  793.      out (lcdinstport),a
  794.      pop af
  795.      ret
  796.  
  797. ; title image
  798.  
  799. title:
  800.  
  801.      .db $01,252,$03,$E0,$00,$00,$00,$00,$00,$00,$00,$00
  802.      .db $07,$06,$02,$20,$00,$00,$00,$00,$00,$00,$00,$00
  803.      .db $0C,$02,$02,$20,$00,$00,$00,$00,$00,$00,$00,$00
  804.      .db $18,$02,$06,$20,$00,$00,$00,$00,$00,$00,$00,$00
  805.      .db $11,$F6,$04,$60,$1F,$C0,$1F,$F8,$01,$FC,$01,$FF
  806.      .db $11,$FC,$04,$40,$70,$60,$10,$0C,$07,$06,$07,$01
  807.      .db $10,$38,$0D,$40,$C0,$30,$30,$04,$0C,$02,$0C,$01
  808.      .db $10,$0C,$0A,$C1,$8F,$10,$23,$C4,$18,$E2,$08,$7B
  809.      .db $19,$04,$0D,$81,$19,$50,$62,$44,$11,$E2,$08,$7E
  810.      .db $0E,$54,$1B,$83,$19,$B0,$E2,$C6,$70,$02,$08,$0C
  811.      .db $7B,$0C,$21,$86,$92,$51,$46,$8D,$A4,$06,$04,$04
  812.      .db $4F,$AC,$20,$C9,$36,$2E,$45,$88,$33,$FD,$1F,$D4
  813.      .db $C1,$DC,$40,$B2,$5C,$60,$47,$00,$29,$E6,$F3,$EC
  814.      .db $80,$B2,$41,$02,$00,$C0,$80,$24,$30,$04,$00,$3C
  815.      .db $C0,$61,$80,$00,$03,$88,$00,$61,$78,$01,$20,$18
  816.      .db $60,$00,$29,$00,$E6,$02,$8F,$DA,$8F,$44,$10,$08
  817.      .db $1E,$04,$10,$00,$01,$C8,$88,$05,$06,$28,$25,$10
  818.      .db $0C,$11,$26,$08,$E1,$41,$98,$02,$01,$82,$18,$20
  819.      .db $02,$86,$99,$23,$16,$23,$10,$00,$00,$44,$37,$C0
  820.      .db $01,$29,$B0,$94,$0A,$18,$F0,$02,$00,$30,$E0,$00
  821.      .db $01,$D8,$C0,$48,$08,$0D,$80,$07,$00,$09,$00,$00
  822.      .db $01,$60,$80,$50,$00,$07,$00,$05,$00,$09,$00,$00
  823.      .db $00,$E0,$00,$50,$00,$04,$00,$08,$80,$06,$00,$00
  824.      .db $00,$C0,$00,$30,$00,$00,$00,$09,$80,$04,$00,$00
  825.      .db $00,$80,$00,$20,$00,$00,$00,$07,$00,$00,$00,$00
  826.  
  827. ; different sprites
  828.  
  829. blank:
  830.  
  831.      .db %00000000
  832.      .db %00000000
  833.      .db %00000000
  834.      .db %00000000
  835.      .db %00000000
  836.      .db %00000000
  837.      .db %00000000
  838.      .db %00000000
  839.  
  840. grass:
  841.  
  842.      .db %00101010
  843.      .db %10100000
  844.      .db %00010101
  845.      .db %01001000
  846.      .db %00100010
  847.      .db %00001100
  848.      .db %01010001
  849.      .db %01000010
  850.  
  851. tree:
  852.  
  853.      .db %00011000
  854.      .db %00011000
  855.      .db %00111100
  856.      .db %00111100
  857.      .db %01111110
  858.      .db %01111110
  859.      .db %11111111
  860.      .db %00011000
  861.  
  862. rock1:
  863.  
  864.      .db %00000000
  865.      .db %00000000
  866.      .db %00001100
  867.      .db %00010010
  868.      .db %00100010
  869.      .db %00100010
  870.      .db %00011100
  871.      .db %00000000
  872.  
  873. rock2:
  874.  
  875.      .db %00000000
  876.      .db %00111000
  877.      .db %01000100
  878.      .db %01010010
  879.      .db %10100001
  880.      .db %10000001
  881.      .db %01000011
  882.      .db %00111100
  883.  
  884. gate:
  885.  
  886.      .db %00000000
  887.      .db %01000010
  888.      .db %01111110
  889.      .db %01111110
  890.      .db %01000010
  891.      .db %01000010
  892.      .db %01000010
  893.      .db %01000010
  894.  
  895. chars:
  896.  
  897.      .db "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  898.      .db "0123456789"
  899.  
  900. editor:
  901.  
  902.      .db "Level Editor",0
  903.  
  904. newstr:
  905.  
  906.      .db "New",0
  907.  
  908. editstr:
  909.  
  910.      .db "Edit",0
  911.  
  912. namestr:
  913.  
  914.      .db "Name:",0
  915.  
  916. selectstr:
  917.  
  918.      .db "Edit:",0
  919.  
  920. nomemstr:
  921.  
  922.      .db "Not Enough Memory",0
  923.  
  924. nolevel1:
  925.  
  926.      .db "There arent any",0
  927.  
  928. nolevel2:
  929.  
  930.      .db "levels to edit",0
  931.  
  932. defaultprog:
  933.  
  934.      .db progobj,"ZSKIL"
  935.  
  936. .end
  937. END