Advertisement
Guest User

prgmGUI

a guest
Jun 13th, 2017
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;--------------->Plasma<------------------
  2. ;Version 1.4
  3. ;
  4. ;The source code to Plasma is freely available.
  5. ;(This includes plasma.asm, gui.asm and load.asm. [It does not include
  6. ;ionlibs.asm this code was written by Joe Wingbermuehle and
  7. ;used with permission. If you would like to use it in your code
  8. ;you must contact Joe Wingbermuehle <jwing@umr.edu>
  9. ;and get his permission.])
  10. ;The source must be packaged with the compiled binaries.
  11. ;Any one can modify, recompile, then distribute the source code.
  12. ;The source must be released on the modified version and must
  13. ;carry this copy right at the top of the source files.
  14. ;Before releasing the program a
  15. ;e-mails explaining what kind of program the code was used for
  16. ;should be sent to the following people:
  17. ;Joe Flint <Joe-F@columbus.rr.com>
  18. ;Brandon Engelberth <reddwarf_lester@yahoo.com>
  19. ;This is so we know if the code is ever actualy used. If you optimize
  20. ;or fix a bug it would be very much appreciated if you would email
  21. ;it to the above people. This way they can be included in the official
  22. ;releases of Plasma.
  23.  
  24. ;Authors:
  25. ;Joe Flint - GUI
  26. ;Joe-F@columbus.rr.com
  27. ;
  28. ;Brandon Engelberth - CORE, LOADER
  29. ;reddwarf_lester@yahoo.com
  30. ;
  31. ;Enjoy!
  32. GDown       .equ 01h
  33. GLeft       .equ 02h
  34. GRight      .equ 03h
  35. GUp     .equ 04h
  36. GMode       .equ 37h
  37. GAlpha      .equ 30h
  38. G2nd        .equ 36h
  39. GEnter      .equ 09h
  40. GF1     .equ 35h
  41. progx   =  gui
  42. numback =   gui+2
  43. count   =   gui+3
  44. Plasmatxt:
  45. #ifdef DEVEL
  46.     .db " Plasma 1.4-dev",0
  47. #else
  48.     .db " Plasma 1.4",0
  49. #endif
  50. #ifdef DEVEL
  51. invalid_key_text:
  52.     .db "Invalid Key:    ",0
  53. wait_key:
  54.     bcall(_getcsc)
  55.     or a
  56.     jr z,wait_key
  57.     ret
  58. #endif
  59. startgui:
  60.     bcall(_indicatoroff)
  61.     bcall(_cleargbuf)
  62.     ld a,8
  63.     ld (progx),a
  64.     xor a
  65.     ld (barup),a
  66.     ld (numback),a
  67.     ld hl,0
  68.     ld (count),hl
  69.     call drawscreen    
  70.     call drawprogtext1
  71.    call drawrect
  72.    call fastcopy    
  73. keyloop:
  74.  
  75.     bcall(_getcsc)
  76.     cp GMODE
  77.     jp z,exit
  78.     or a
  79.    
  80.     call nz,resetcount
  81.     ld hl,keyloop
  82.     push hl
  83.    
  84.     cp GDown
  85.     jp z,movedown
  86.     cp GUP
  87.     jp z,moveup
  88.  
  89.     cp Galpha
  90.     jp z,showbar
  91.     cp Genter
  92.     jr z,runprog
  93.     cp gf1
  94.     jr z,runprog
  95.     cp g2nd
  96.     jr z,runprog
  97.     cp Gright
  98.     jp z,pagedown
  99.     cp gleft
  100.     jp z,pageup
  101.  
  102.     pop hl
  103. #ifdef DEVEL
  104.     push af
  105. #endif
  106.     in a,(0)
  107.     cp 3
  108.     jp nz,exit
  109.     ld hl,(count)
  110.     inc hl
  111.     ld (count),hl
  112.     ld de,40000
  113.     bcall(_cphlde)
  114.     jp z,exit
  115. #ifdef DEVEL
  116.     pop af
  117.     or a
  118.     jr z,keyloop
  119.     set textInverse, (iy+textflags)
  120.     ld h,$00
  121.     ld l,a
  122.     xor a
  123.     ld (penrow),a  
  124.     ld a,70
  125.     ld (pencol),a
  126.     bcall(_setxxxxop2)
  127.     bcall(_op2toop1)
  128.     ld a,5
  129.     bcall(_dispop1a)
  130.     res textInverse, (iy+textflags)
  131.     ;call FastCopy
  132.    
  133. #endif
  134.     jr keyloop
  135. resetcount:
  136.  
  137.     ld hl,0
  138.     ld (count),hl
  139.     ret        
  140. runprog:
  141.     ;bcall(_cleargbuf)
  142.     call exec_prog
  143.     bcall(_cleargbuf)
  144.     call redrawt
  145.     call drawscreen
  146.     call drawrect
  147.     jp fastcopy
  148.  
  149. redrawt:
  150.     ld a,(numback)
  151.     ld b,a
  152.     ;inc b
  153.     or a
  154.     call nz,jump_prev_b_progs
  155.     call drawprogtext1
  156.     ld a,(numback)
  157.     ld b,a
  158.     or a
  159.     ret z
  160.     call jump_next_b_progs
  161.     ret        
  162. drawscreen:
  163.    ld d,0
  164.    ld e,6
  165.    ld c,1
  166.    ld b,96
  167.    call H_line
  168.    ld e,5
  169.    ld b,95
  170.    call H_line
  171.     ld e,1
  172.     ld b,6
  173.     call V_line
  174.     ld d,37
  175.     call V_line    
  176.    
  177.     ld a,1
  178.     ld (pencol),a
  179.     xor a
  180.     ld (penrow),a
  181.     ld hl,plasmatxt
  182.    SET textwrite, (IY+sgrflags)
  183.     set textInverse, (iy+textflags) ; Sets inverse.
  184.    bcall(_vputs)    
  185.     res textInverse, (iy+textflags) ; Sets inverse.  
  186.     res textwrite, (iy+sgrflags)    
  187.     ret
  188. barup:
  189.     .db 0
  190.      
  191. exit:
  192.     bcall(_clrscrf)    
  193.     bcall(_homeup)
  194.     bcall(_cleargbuf)
  195.     set 3, (iy+$24)
  196.     ret
  197. drawprogtext1:
  198.    SET textwrite, (IY+sgrflags)
  199.     xor a
  200.     ld (pencol),a
  201.     ld a,8
  202.     ld (penrow),a
  203.     ld e,0  
  204.    ld b,9    
  205. drawprogtext:  
  206.     push bc
  207.     push de
  208.     ld hl,Data_Prog_Desc
  209.     bcall(_vputs)
  210.     xor a
  211.     ld (pencol),a
  212.     call next_prog
  213.     or a
  214.     jp z,nomoreprogs
  215.     pop de
  216.     inc e
  217.     ld a,(penrow)
  218.     add a,6
  219.     ld (penrow),a
  220.     pop bc
  221.     djnz drawprogtext
  222.     ld a,56
  223.     ld (mstop+1),a
  224. backtothis:
  225.     ld a,e
  226.     ld b,e
  227.     or a
  228.     call nz,jump_prev_b_progs            
  229.     res textwrite, (IY+sgrflags)
  230.     ret
  231. nomoreprogs:
  232.     pop de
  233.     pop bc
  234.     ld a,(penrow)
  235.     ld (mstop+1),a
  236.     jp backtothis        
  237. movedown:
  238.     ld a,(barup)
  239.     dec a
  240.     call z,fixtext
  241.     ld a,(progx)
  242. mstop:    
  243.     cp 56
  244.     jp z,newprogdown
  245.     ld b,6
  246. movedownl:
  247.     push bc
  248.     call drawrect
  249.     ld a,(progx)
  250.     inc a
  251.     ld (progx),a
  252.     call drawrect
  253.     call FastCopy
  254.     pop bc    
  255.     djnz movedownl
  256.     xor a
  257.     ld (barup),a
  258.     ld a,(numback)
  259.     inc a
  260.     ld (numback),a
  261.     jp next_prog
  262. moveup:
  263.     ld a,(barup)
  264.     dec a
  265.     call z,fixtext
  266.     ld a,(progx)
  267.     cp 8
  268.     jp z,newprogup
  269.     ld b,6
  270. moveupl:
  271.     push bc
  272.     call drawrect
  273.     ld a,(progx)
  274.     dec a
  275.     ld (progx),a
  276.     call drawrect
  277.     call FastCopy
  278.     pop bc    
  279.     djnz moveupl
  280.     xor a
  281.     ld (barup),a
  282.     ld a,(numback)
  283.     dec a
  284.     ld (numback),a
  285.     jp prev_prog
  286. dispsize:
  287.     ld a,(progx)
  288.     ld (penrow),a  
  289.     ld a,40
  290.     ld (pencol),a
  291.     ld hl,(Data_Prog_Size)
  292.     bcall(_setxxxxop2)
  293.     bcall(_op2toop1)
  294.     ld a,5
  295.     bcall(_dispop1a)
  296.     ret
  297. pageup:
  298.     ;ld b,9
  299. pageup1:
  300.     ;push bc
  301.     ;call moveup
  302.     ;pop bc
  303.     ;djnz pageup1    
  304.     ;ret
  305.     ld b,9
  306.     call jump_prev_b_progs
  307.     cp 9
  308.     jp nz,fix2
  309.     ld a,(numback)
  310.     ld b,a
  311.     or a
  312.     call nz,jump_prev_b_progs
  313.     bcall(_cleargbuf)
  314.     call drawscreen
  315.     call drawprogtext1
  316.     ld a,(numback)
  317.     ld b,a
  318.     or a
  319.     call nz,jump_next_b_progs
  320.     call drawrect
  321.     call fastcopy    
  322.     ret    
  323.  
  324. pagedown:
  325.     ;ld b,9
  326. pagedown1:
  327.     xor a
  328.     ld (pencol),a
  329.     ld (penrow),a
  330.     ;push bc
  331.     ;call movedown
  332.     ;pop bc
  333.     ;djnz pagedown1
  334.     ;ret    
  335.     ld a,(numback)
  336.     ld b,a
  337.     or a
  338.     call nz,jump_prev_b_progs
  339.     ld b,9
  340.     call jump_next_b_progs
  341.     cp 9
  342.     jp z,godraw
  343. nogo:
  344.     ld b,a
  345.     or a
  346.     call nz,jump_prev_b_progs
  347.     ld a,(numback)
  348.     ld b,a
  349.     or a
  350.     call nz,jump_next_b_progs
  351.     xor a ;Yes i'm cheating, so what
  352.     ret        
  353.    
  354. godraw:
  355.     bcall(_cleargbuf)
  356.     call drawscreen
  357.     call drawprogtext1
  358.     ld a,(numback)
  359.     ld b,a
  360.     or a
  361.     call nz,jump_next_b_progs
  362.     ld (numback),a
  363.     ld a,(mstop+1)
  364.     ld b,a
  365.     ld a,(progx)
  366.     cp b
  367.     call p,nomore
  368.     call drawrect
  369.     call fastcopy
  370.     ret
  371. fix2:
  372.     ld b,a
  373.     or a
  374.     call nz,jump_next_b_progs
  375.     ret        
  376.    
  377. nomore:
  378.     ld a,(mstop+1)
  379.     ld (progx),a
  380.     ret        
  381. newprogdown:
  382.     call next_prog
  383.     or a
  384.     ret z
  385.     ld a,(numback)
  386.     ld b,a
  387.     call jump_prev_b_progs
  388.     ld a,(progx)
  389.     sub 6
  390.     ld (progx),a
  391.     bcall(_cleargbuf)
  392.     call drawscreen
  393.     call drawprogtext1
  394.     ld a,(numback)
  395.     dec a
  396.     ld b,a
  397.     call jump_next_b_progs
  398.     call drawrect
  399.     ld a,(numback)
  400.     dec a
  401.     ld (numback),a    
  402.     jp movedown
  403.     ret
  404. newprogup:
  405.     call prev_prog
  406.     or a
  407.     ret z
  408.     ld a,(progx)
  409.     add a,6
  410.     ld (progx),a
  411.     bcall(_cleargbuf)
  412.     call drawscreen
  413.     call drawprogtext1
  414.     call next_prog
  415.     call drawrect
  416.     ld a,(numback)
  417.     inc a
  418.     ld (numback),a    
  419.     jp moveup
  420.     ret
  421. showbar:
  422.  
  423.     ld c,1
  424.     ld b,96
  425.     ld d,0
  426.     ld a,(progx)
  427.     ld e,a
  428.     call h_line
  429.     inc e
  430.     call h_line
  431.     inc e
  432.     call h_line
  433.     inc e
  434.     call h_line
  435.     inc e
  436.     call h_line
  437.     inc e
  438.     call h_line
  439.     inc e
  440.     call h_line
  441.     ld a,(progx)
  442.     ld (penrow),a
  443.     xor a
  444.     ld (pencol),a
  445.  
  446.     set textInverse, (iy+textflags) ; Sets inverse.
  447.  
  448.    set textwrite, (IY+sgrflags)
  449.    ld a,(Data_Flash_off_set)
  450.    or a
  451.    jp z,inram
  452.    ld hl,ast
  453.    bcall(_vputs)
  454. inram:
  455.     ld hl,Data_Prog_Name  
  456.     bcall(_vputs)
  457.     call dispsize
  458.    res textwrite, (IY+sgrflags)
  459.     res textInverse, (iy+textflags) ; Sets inverse.
  460.    
  461.     call FastCopy
  462.     ld a,1
  463.     ld (barup),a    
  464.     ret
  465.  
  466. drawrect:
  467.     ld c,2
  468.     ld b,96
  469.     ld d,0
  470.     ld a,(progx)
  471.     ld e,a
  472.     call h_line
  473.     inc e
  474.     call h_line
  475.     inc e
  476.     call h_line
  477.     inc e
  478.     call h_line
  479.     inc e
  480.     call h_line
  481.     inc e
  482.     call h_line
  483.     inc e
  484.     call h_line
  485.     ret    
  486. ast:
  487.     .db "*",0          
  488. fixtext:
  489.     ld c,1
  490.     ld b,96
  491.     ld d,0
  492.     ld a,(progx)
  493.     ld e,a
  494.     call h_line
  495.     inc e
  496.     call h_line
  497.     inc e
  498.     call h_line
  499.     inc e
  500.     call h_line
  501.     inc e
  502.     call h_line
  503.     inc e
  504.     call h_line
  505.     inc e
  506.     call h_line    
  507.     ld a,(progx)
  508.     ld (penrow),a
  509.     xor a
  510.     ld (pencol),a
  511.     ld hl,Data_Prog_Desc
  512.     set textInverse, (iy+textflags) ; Sets inverse.
  513.  
  514.    set textwrite, (IY+sgrflags)    
  515.     bcall(_vputs)
  516.    res textwrite, (IY+sgrflags)
  517.     res textInverse, (iy+textflags) ; Sets inverse.
  518.     ret                
  519.  
  520.    
  521.                      
  522.  
  523. Getpix: ld d, 0
  524.         ld h, d
  525.         ld l, e
  526.         add hl, de
  527.         add hl, de
  528.         add hl, hl
  529.         add hl, hl
  530.         ld de, Plotsscreen
  531.         add hl, de
  532. Getbit: ld b, 0
  533.         ld c, a
  534.         and %00000111
  535.         srl c
  536.         srl c
  537.         srl c
  538.         add hl, bc
  539.         ld b, a
  540.         inc b
  541.         ld a, %00000001
  542. GBLoop: RRCA
  543.         djnz GBLoop
  544.         ret
  545. V_Line:
  546.         push de
  547.         push hl
  548.         push bc
  549.         ld a, d
  550.         call Getpix
  551.         pop bc
  552.         push bc
  553.         ld d, c
  554.         ld c, a
  555.         ld a, d
  556.         ld de, 12
  557.         or a
  558.         call z, V_White_Line
  559.         dec a
  560.         call z, V_Black_Line
  561.         dec a
  562.         call z, V_XORed_Line
  563.         pop bc
  564.         pop hl
  565.         pop de
  566.         ret
  567.  
  568. V_White_Line:
  569.         ld a, c
  570.         CPL
  571.         ld c, a
  572. V_White_Line_2:
  573.         ld a, (hl)
  574.         and c
  575.         ld (hl), a
  576.         add hl, de
  577.         DJNZ V_White_Line_2
  578.         xor a
  579.         ret
  580.  
  581. V_Black_Line:
  582.         ld a, (hl)
  583.         or c
  584.         ld (hl), a
  585.         add hl, de
  586.         DJNZ V_Black_Line
  587.         xor a
  588.         ret
  589.  
  590. V_XORed_Line:
  591.         ld a, (hl)
  592.         xor c
  593.         ld (hl), a
  594.         add hl, de
  595.         DJNZ V_XORed_Line
  596.         ret
  597.  
  598. H_Line:
  599.         push de
  600.         push hl
  601.         push bc
  602.         ld a, d
  603.         call Getpix
  604.         pop bc
  605.         push bc
  606.         ld d, c
  607.         ld c, a
  608.         ld a, d
  609.         or a
  610.         call z, H_White_Line
  611.         dec a
  612.         call z, H_Black_Line
  613.         dec a
  614.         call z, H_XORed_Line
  615.         pop bc
  616.         pop hl
  617.         pop de
  618.         ret
  619.  
  620. H_White_Line:
  621.         ld a, c
  622.         CPL
  623.         ld c, a
  624. H_White_Line_2:
  625.         ld a, (hl)
  626.         and c
  627.         ld (hl), a
  628.         RR c
  629.         jr c, Cont_H_White_Line
  630.         inc hl
  631.         RR c
  632. Cont_H_White_Line:
  633.         DJNZ H_White_Line
  634.         xor a
  635.         ret
  636.  
  637. H_Black_Line:
  638.         ld a, (hl)
  639.         or c
  640.         ld (hl), a
  641.         RR c
  642.         jr nc, Cont_H_Black_Line
  643.         inc hl
  644.         RR c
  645. Cont_H_Black_Line:
  646.         DJNZ H_Black_Line
  647.         xor a
  648.         ret
  649.  
  650. H_XORed_Line:
  651.         ld a, (hl)
  652.         xor c
  653.         ld (hl), a
  654.         RR c
  655.         jr nc, Cont_H_XORed_Line
  656.         inc hl
  657.         RR c
  658. Cont_H_XORed_Line:
  659.         DJNZ H_XORed_Line
  660.         ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement