home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser 2002 January / STC_CD_01_2002.iso / GAMES / COLUMSRC / GUW_MAC2.S < prev    next >
Text File  |  1994-01-09  |  13KB  |  678 lines

  1.     opt o+,ow-
  2. *MOD_BOX=1
  3. *MOD_HEXA=1
  4. *MOD_DECI=1
  5.  
  6.     ; Revues : 24/7/93 : 27/7/93 : 29/7/93 : 07/08/93 : 14/08/93 : 23/08/93
  7.     ; 24/8/93 : 03-IX-93 : 04-IX-93 : 06-IX-93 : 11-IX-93 : 29-X-93
  8.     ; 27-XI-93 : 05-XII-93 : 18-XII
  9.     ; Last revue : Gen&wax
  10.  
  11. dos    = 1
  12. bios    = 13
  13. xbios    = 14
  14. esc    = 27
  15. lf    = 10
  16. rc    = 13
  17.  
  18. ecran    = $44e
  19. futur_ecran = $45e
  20. vbl_cpt    = $466
  21. cpt_200    = $4ba
  22. vblqueue    = $4ce+4
  23. enable_vbl  = $452
  24. hbl    = $68
  25. palette    = $ffff8240
  26. palette256    = $ffff9800
  27. chipsonore    = $ffff8800
  28. chipvideo    = $ffff8205
  29. clavier    = $fffffc02
  30. dma    = $ffff8604
  31. datac    = $fffffa23
  32. datad    = $fffffa25
  33. ctrlcd    = $fffffa1d
  34. timera    = $134
  35. dataa    = $fffffa1f
  36. ctrla    = $fffffa19
  37. timerb    = $120
  38. datab    = $fffffa21
  39. ctrlb    = $fffffa1b
  40. zilog8530    = $ffff8c85
  41. zilogrs    = $ffff8c87        ; zilog send/receive register
  42. dsp_host_isr= $ffffa202
  43. dsp_host    = $ffffa204
  44.  
  45. read=0            ; pour file open, write ...
  46. write=1
  47. read_write=2
  48.  
  49. res64048016vga    = $3a    ; pour set mode : tout est en PAL
  50. res640480256vga    = $3b
  51. res320480tcvga    = $34
  52. res32020016vga    = $1b2    ; compatible basse
  53. res32024016vga    = $132
  54. res32048016vga    = $32
  55. res320240256vga    = $133
  56. res320240tcvga    = $134
  57. res64040016tv    = $12a
  58. res640400256tv    = $12b
  59. res320400tctv    = $124
  60. res32020016tv    = $a2    ; compatible basse
  61. res320200256tv    = $23
  62. res320200tctv    = $24
  63.  
  64. freq8    = %00001011
  65. freq10    = %00001001
  66. freq12    = %00000111
  67. freq16    = %00000101
  68. freq20    = %00000100
  69. freq25    = %00000011
  70. freq33    = %00000010
  71. freq49    = %00000001
  72.  
  73. SAVE:    macro
  74.     movem.l \1,-(sp)
  75.     endm
  76.  
  77. LOAD:    macro
  78.     movem.l (sp)+,\1
  79.     endm
  80.  
  81. APPEL:    macro
  82.     move.w #\2,-(sp)
  83.     trap #\1
  84.     ifle \3-8
  85.     addq.l #\3,sp
  86.     else
  87.     add.l #\3,sp
  88.     endc
  89.     endm
  90.  
  91. WAIT:    macro
  92.     appel dos,7,2
  93.     endm
  94.  
  95. INIT:    macro
  96.     move.l a7,a5
  97.     lea pile,a7
  98.     move.l 4(a5),a5
  99.     move.l 12(a5),d0
  100.     add.l 20(a5),d0
  101.     add.l 28(a5),d0
  102.     add.l #$100,d0
  103.     and.l #-2,d0
  104.     addq.l #2,d0
  105.     move.l d0,-(sp)
  106.     move.l a5,-(sp)
  107.     clr.w -(sp)
  108.     appel dos,$4a,12
  109.     BSS
  110.     ds.l 4096
  111. pile:    ds.l 1
  112.     TEXT
  113.     endm
  114.  
  115. SUPERVISOR:    macro
  116.     clr.l -(sp)
  117.     appel dos,$20,6
  118.     move.l d0,old_stack
  119.     endm
  120.     BSS
  121. old_stack:    ds.l 1
  122.     TEXT
  123.  
  124. USER:    macro
  125.     move.l old_stack,-(sp)
  126.     appel dos,$20,6
  127.     endm
  128.  
  129. SUP_EXEC:    macro
  130.     pea \1
  131.     appel xbios,38,6
  132.     endm
  133.  
  134. SYNCRO:    macro
  135.     appel xbios,$25,2
  136.     endm
  137.     
  138. SYNCRO_GEM:    macro
  139. \@wait_nul:    appel dos,$0b,2    ; teste du buffer ...
  140.     tst.w d0
  141.     beq.s \@the_end    ; pas de touche en buffer ?
  142.     wait
  143.     bra.s \@wait_nul
  144. \@the_end:    syncro
  145.     syncro
  146.     endm
  147.  
  148. RESOLUT:    macro        ; \1=vidéo mode,\2=0:ST / \2=3:FALC
  149.     move.w \1,-(sp)
  150.     move.w \2,-(sp)
  151.     move.l \3,-(sp)
  152.     move.l \3,-(sp)
  153.     appel xbios,5,14
  154.     syncro_gem
  155.     endm
  156.  
  157. SET_MODE:    macro
  158.     move.w \1,-(sp)
  159.     appel xbios,88,4
  160.     endm
  161.  
  162. MOUSEOFF:    macro
  163.     pea inhibe
  164.     move.w #1-1,-(sp)
  165.     appel xbios,25,8
  166.     DATA
  167. inhibe:    dc.b $12
  168.     even
  169.     TEXT
  170.     endm
  171.  
  172. MOUSEON:    macro
  173.     pea default
  174.     move.w #2-1,-(sp)
  175.     appel xbios,25,8
  176.     endm
  177.     DATA
  178. default:    dc.b $80,$01
  179.     TEXT
  180.  
  181. WRITE:    macro
  182.     pea \1
  183.     appel dos,9,6
  184.     endm
  185.  
  186. SET_GEM:    macro
  187.     init
  188.     ifne MOD_BOX
  189.     bsr init_box
  190.     endc
  191.     endm
  192.  
  193. RESTORE_GEM:macro
  194.     syncro_gem
  195.     ifne MOD_BOX
  196.     bsr end_box
  197.     endc
  198.     move.w erreur_fils,-(sp)
  199.     appel dos,$4c,4    ; Pterm
  200.  DATA
  201. erreur_fils:dc.w 0
  202.  TEXT
  203.     endm
  204.  
  205. RESTORE_GEM_RES:macro        ; \1=taille à protéger
  206.     syncro_gem
  207.     ifne MOD_BOX
  208.     save \1
  209.     bsr end_box
  210.     load \1
  211.     endc
  212.     clr.w -(sp)
  213.     move.l \1,-(sp)
  214.     appel dos,$31,8    ; laisse résident le programme
  215.     endm
  216.  
  217. RESTORE_GEM_ERR:macro
  218.     move.w \1,erreur_fils
  219.     restore_gem
  220.     endm
  221.  
  222. FILE_OPEN:    macro        ; \1=read/write \2=name
  223.     ifeq \1-1        ; 0=lecture,other=write
  224.     clr.w -(sp)
  225.     pea \2
  226.     appel dos,$3c,8    ; file create
  227.     endc
  228.     ifeq \1
  229.     clr.w -(sp)
  230.     pea \2
  231.     appel dos,$3d,8    ; file open
  232.     endc
  233.     ifeq \1-2
  234.     move.w #2,-(sp)
  235.     pea \2
  236.     appel dos,$3d,8
  237.     endc
  238.     endm
  239.  
  240. FILE_READ:    macro        ; \1 =ad. \2=nb. \3=handle
  241.     move.l \1,-(sp)
  242.     move.l \2,-(sp)    ; nb
  243.     move.w \3,-(sp)
  244.     appel dos,$3f,12    ; file read
  245.     endm
  246.  
  247. FILE_WRITE:    macro        ; \1 =ad. \2=nb. \3=handle
  248.     move.l \1,-(sp)
  249.     move.l \2,-(sp)
  250.     move.w \3,-(sp)
  251.     appel dos,$40,12    ; file write
  252.     endm
  253.  
  254. FILE_SEEK:    macro        ; \1 =seekmode, \2=handle, \3=offset.l
  255.     move.w \1,-(sp)
  256.     move.w \2,-(sp)
  257.     move.l \3,-(sp)
  258.     appel dos,$42,10    ; file seek
  259.     endm
  260.  
  261. FILE_CLOSE:    macro        ; \1=handle
  262.     move.w \1,-(sp)    ; fclose
  263.     appel dos,$3e,4
  264.     endm
  265.  
  266. FS_FIRST:    macro
  267.     move.w \1,-(sp)
  268.     pea \2
  269.     appel dos,$4e,8    ; fsfirst
  270.     endm
  271.  
  272. FS_NEXT:    macro
  273.     appel dos,$4f,2    ; fsnext
  274.     endm
  275.  
  276. GET_DRIVE:    macro
  277.     appel dos,$19,2    ; get current drive
  278.     endm
  279.  
  280. SET_DRIVE:    macro
  281.     move \1,-(sp)
  282.     appel dos,$e,4    ; d_set_drive
  283.     endm
  284.  
  285. GET_PATH:    macro
  286.     move.w \1,-(sp)
  287.     pea \2        ; + \sources\
  288.     appel dos,$47,8    ; get_path
  289.     endm
  290.  
  291. SET_PATH:    macro
  292.     pea \1
  293.     appel dos,$3b,6    ; d_set_path
  294.     endm
  295.  
  296. SET_DTA:    macro
  297.     pea \1
  298.     appel dos,$1a,6    ; fset dta
  299.     endm
  300.  
  301. GET_DTA:    macro
  302.     appel dos,$2f,2    ; fget dta
  303.     endm
  304.  
  305. RESERVE_SCREENS:macro        ; \1=nb.ecr \2=resolut
  306.             ; + x_max_p,y_max_p,nb_bits_per_pix
  307.     move.l #screens,d0
  308.     and.l #$ffffff00,d0
  309.     add.l #$100,d0
  310.     move.l d0,a0
  311.     lea ecrans,a1
  312.  
  313.     move #\1-1,d0
  314. .raz_screens:move.l a0,(a1)+
  315.     move.l #x_max_p*y_max_p*nb_bits_per_pix/8/4,d1
  316. .raz_screen:clr.l (a0)+
  317.     subq.l #1,d1
  318.     bne.s .raz_screen
  319.     dbf d0,.raz_screens
  320.  
  321.     move.l ecran,save_ad_ecr
  322.     set_mode #-1
  323.     move d0,save_mode
  324.  
  325.     move #\2,d1
  326.     btst #5,d0
  327.     bne.s .pal_modus
  328.     bclr #5,d1
  329.  
  330. .pal_modus:    btst #4,d0        ; tv
  331.     bne.s .vga_modus
  332.     bclr #4,d1        ; tv
  333.     bchg #8,d1        ; vertical mode
  334. .vga_modus:
  335.     ifne (\2-res32020016tv)*(\2-res32020016vga)
  336.     resolut d1,#3,ecrans,ecrans
  337.     else
  338.     resolut d1,#0,ecrans,ecrans
  339.     endc
  340.     *set_mode \2        ; toujours après resolut !
  341.  
  342.     BSS
  343. save_mode:    ds.w 1
  344. save_ad_ecr:ds.l 1
  345. ecrans:    ds.l \1
  346. screens:    ds.l \1*x_max_p*y_max_p*nb_bits_per_pix/8/4
  347.     ds.b 256
  348.     TEXT
  349.     endm
  350.  
  351. RESTORE_SCREENS:macro
  352.     resolut save_mode,#3,save_ad_ecr,save_ad_ecr
  353.     *set_mode save_mode
  354.     endm
  355.  
  356. SAVE_PALETTES:macro
  357.     syncro
  358.     lea palette256,a0
  359.     lea old_palette256,a1
  360.     move #256-1,d0
  361. .cop_p:    move.l (a0)+,(a1)+
  362.     dbf d0,.cop_p
  363.     lea palette,a0
  364.     lea old_palette16,a1
  365.     move #16-1,d0
  366. .cop_p1:    move.w (a0)+,(a1)+
  367.     dbf d0,.cop_p1
  368.     BSS
  369. old_palette256:ds.l 256
  370. old_palette16:ds.w 16
  371.     TEXT
  372.     endm
  373.  
  374. RESTORE_PALETTES:macro
  375.     syncro
  376.     lea old_palette256,a0
  377.     lea palette256,a1
  378.     move #256-1,d0
  379. .res_p:    move.l (a0)+,(a1)+
  380.     dbf d0,.res_p
  381.     lea old_palette16,a0
  382.     lea palette,a1
  383.     move #16-1,d0
  384. .res_p1:    move.w (a0)+,(a1)+
  385.     dbf d0,.res_p1
  386.     endm
  387.  
  388. COLOR256:    macro
  389.     ifne TCOLOR
  390.     move.l \1,palette256
  391.     endc
  392.     endm
  393.  
  394. COLOR:    macro
  395.     ifne TCOLOR
  396.     move.w \1,palette
  397.     endc
  398.     endm
  399.  
  400. ZILOGR:    macro        ; zilog read : \1=register \2=byte
  401.     move.b \1,zilog8530
  402.     move.b zilog8530,\2
  403.     endm
  404.  
  405. ZILOGW:    macro        ; zilog write : \1=register \2=byte
  406.     move.b \1,zilog8530
  407.     move.b \2,zilog8530
  408.     endm
  409. ***************************************************************************
  410.  
  411.     ifne MOD_BOX+MOD_HEXA+MOD_DECI
  412. START_CODE:    bra debut
  413.     endc
  414.  
  415.     ifne MOD_BOX
  416.     include gemmacro.i
  417. ***************************************************************************
  418.     ; lea boite,a0 : bsr ALERT_BOX ou bsr FILESELECT
  419.     ; pour fileselect => tst d4 : beq annule
  420.  TEXT
  421. init_box:    appl_init
  422.     move.w d0,ap_id    ; store the application id
  423.     rts
  424.  
  425. end_box:    appl_exit
  426.     rts
  427.  
  428. init_mouse:    graf_mouse #257
  429.     graf_mouse #0
  430.     rts
  431.  
  432. desact_mouse:
  433.     graf_mouse #256
  434.     rts
  435.  
  436. ;--------------------------------------------------------------
  437. ; retourne dans d0 le numéro du bouton 1..3
  438. ALERT_BOX:    form_alert default_button,a0    ; bouton gauche par défaut
  439.     move.w int_out,d0        ; quel bouton ?
  440.     rts
  441.  
  442. ;--------------------------------------------------------------
  443. copy_in2_select:
  444.     lea text_fsel,a1
  445. .recop_fsel:move.b (a0)+,(a1)+
  446.     tst.b -1(a0)
  447.     bne.s .recop_fsel
  448.     rts
  449.  
  450. FILESELECT:    get_drive        ; d_get_driv
  451.  
  452.     lea disk_path,a4
  453.     move.b #'A',(a4)
  454.     add.b d0,(a4)+
  455.     move.b #':',(a4)+    ; A: ou B: ...
  456.  
  457.     get_path #0,(a4)
  458.  
  459. .trouv_zer:    tst.b (a4)+
  460.     bne.s .trouv_zer    ; on rajoute \ à la fin
  461.     move.b #'\',-1(a4)
  462.     clr.b (a4)
  463.     
  464.     lea whato,a0
  465. .recop_whato:
  466.     move.b (a0)+,(a4)+    ; ajoute le masque
  467.     tst.b -1(a4)
  468.     bne.s .recop_whato
  469.  
  470.     sup_exec tos_version
  471.     move tos_ver,d7
  472.     cmp.w #$0104,d7
  473.     bge.s its_a_ste
  474.     fsel_input #disk_path,#params_it
  475.     bra.s its_no_a_ste
  476. its_a_ste:    fsel_exinput #disk_path,#params_it,#text_fsel
  477. its_no_a_ste:
  478.     tst.w d0
  479.     beq.s .problem
  480.     move.w int_out+2,d4    ; 'ANNULE','CONFIRME'
  481.  
  482.     lea disk_path,a2
  483. .pas0:    tst.b (a2)+
  484.     bne.s .pas0
  485. .pas_trouv_d:
  486.     cmpi.b #'\',-(a2)
  487.     beq.s .found_slash
  488.     cmpi.b #':',(a2)
  489.     bne.s .pas_trouv_d
  490.     addq.l #1,a2
  491.     move.b #'\',(a2)        ; root
  492. .found_slash:clr.b 1(a2)        ; chemin fini par 0
  493.     lea disk_path,a4
  494.     cmpi.b #':',1(a4)
  495.     bne.s .pas_driv
  496.     clr d0
  497.     move.b (a4),d0
  498.     ori.b #32,d0
  499.     subi.b #'a',d0
  500.     set_drive d0
  501.     addq.l #2,a4
  502.  
  503. .pas_driv:    set_path (a4)
  504.     tst d0
  505.     bne.s .problem
  506.  
  507.     lea params_it,a2
  508.     tst.b (a2)
  509.     bne.s .o_k        ; si plante ouvrir n'importe (le 1er)
  510.     move.l #'*.*'*256,(a2)    ; *.* 0
  511. .o_k:
  512. .problem:    rts
  513.  
  514. tos_version:move.l $4f2.w,a0        ; Adresse de la ROM
  515.     move.w 2(a0),tos_ver
  516.     rts
  517.  
  518. test_slct:    move.l $5a0.w,a0
  519.     cmp.l #0,a0
  520.     beq.s notfound
  521. .next:    tst.l (a0)
  522.     beq.s notfound
  523.     cmp.l #'FSEL',(a0)
  524.     beq.s .found
  525.     lea 8(a0),a0
  526.     bra.s .next
  527. .found:    move.l 4(a0),a0
  528.     cmp.l #'SLCT',(a0)
  529.     bne.s notfound
  530.     move.l a0,sltr_adress
  531.     lea 4+2+2+2+2+4+2+4(a0),a0
  532.     move.l a0,sltr_communication_word
  533.     lea 2+2+4(a0),a0
  534.     move.l a0,sltr_out_counter
  535.     lea 2(a0),a0
  536.     move.l a0,sltr_out_pointer
  537. notfound:    rts
  538.  BSS
  539. tos_ver:        ds.w 1
  540. sltr_adress:    ds.l 1        ; Selctrix base adress (0 si pas sélectrix)
  541. sltr_communication_word:ds.l 1        ; ad. du word communication
  542. sltr_out_counter:    ds.l 1        ; ad. du compteur sortie
  543. sltr_out_pointer:    ds.l 1        ; ad. du pointeur sortie
  544.  TEXT
  545. ;--------------------------------------------------------------
  546.     include aeslib.s
  547. ;--------------------------------------------------------------
  548.  DATA
  549.  even
  550. default_button:
  551.     dc.w 1
  552.  
  553. whato:    dc.b '*.*',0,0,0
  554. text_fsel:    dc.b 'Choose The File :'
  555.     dcb.b 80,0
  556.  even
  557.  BSS
  558. ap_id:    ds.w 1
  559.  
  560. disk_path:    ds.b 256
  561. params_it:    ds.b 8+1+3+1    ; fileselect filename.
  562.  even
  563.  TEXT
  564. ***************************************************************************
  565.     endc
  566.  
  567.     ifne MOD_HEXA
  568. ***************************************************************************
  569. HEXA:    sub #4,d1        ; sous routine d'affichage hexa d'1 registre
  570.     move.l d0,d2    ; d1=nb bits
  571.     lsr.l d1,d2        ; d0=donnée
  572.     and.w #$f,d2
  573.     cmp #$a,d2
  574.     bge.s .lettr
  575.     add.b #'0',d2
  576.     bra.s .fin_lettr
  577. .lettr:    add.b #'A'-$a,d2
  578. .fin_lettr:    save d0-d2/a0
  579.     move.w d2,-(sp)
  580.     appel dos,2,4
  581.     load d0-d2/a0
  582.     tst d1
  583.     bgt.s hexa
  584.     rts
  585. ***************************************************************************
  586.     endc
  587.  
  588.     ifne MOD_DECI
  589. ***************************************************************************
  590. DECI:    lea affiche_decim,a0    ; dans d0 la donnée à afficher 0<9999
  591.     *ext.l d0
  592.  
  593.     tst.l d0
  594.     beq .it_s_0
  595.  
  596.     move.l #10000000*10,d2    ; sur 8 décimales max
  597.  
  598. .until_frac0:divul #10,d3:d2    ; reste:fraction
  599.     tst.l d2
  600.     beq.s .dernier
  601.  
  602.     divul d2,d1:d0    ; reste:fraction
  603.     add.b #'0',d0
  604.     move.b d0,(a0)+
  605.     move.l d1,d0
  606.     bra.s .until_frac0
  607.  
  608. .dernier:    clr.b (a0)+
  609.  
  610.     lea affiche_decim,a0
  611. .first_non0:cmp.b #'0',(a0)+
  612.     beq.s .first_non0
  613.     lea -1(a0),a0
  614. .reb:    write (a0)
  615.     rts
  616.  
  617. .it_s_0:    move.w #'0'*256,affiche_decim
  618.     bra.s .reb
  619.  
  620.     BSS
  621. affiche_decim:
  622.     ds.b 8+1
  623.     even
  624.     TEXT
  625. ***************************************************************************
  626.     endc
  627.     
  628. ;SAVE        sauve une série de registres (movem)
  629. ;LOAD        restaure "
  630. ;APPEL
  631. ;WAIT
  632. ;INIT
  633. ;SUPERVISOR
  634. ;USER        ~après SUPERVISOR~
  635. ;SUP_EXEC        PEA \1 = adresse
  636. ;SYNCRO
  637. ;SYNCRO_GEM
  638. ;RESOLUT        \1=vidéo mode,\2=0:ST / \2=3:FALC
  639. ;SET_MODE
  640. ;MOUSEOFF
  641. ;MOUSEON
  642. ;WRITE        PEA\1 texte
  643. ;SET_GEM
  644. ;RESTORE_GEM        ~après~ SET_GEM
  645. ;RESTORE_GEM_RES    ~après~ SET_GEM  \1=taille à protéger
  646. ;RESTORE_GEM_ERR    ~après~ SET_GEM  \1=code à renvoyer à l'appelant
  647. ;FILE_OPEN        \1=read/write PEA\2=name
  648. ;FILE_READ        \1 =ad. \2=nb. \3=handle
  649. ;FILE_WRITE        \1 =ad. \2=nb. \3=handle
  650. ;FILE_SEEK        \1 =seekmode, \2=handle, \3=offset.l
  651. ;FILE_CLOSE        \1=handle
  652. ;FS_FIRST        \1=#type(fichier,directory), PEA\2=name
  653. ;FS_NEXT
  654. ;GET_DRIVE        renvoie d0=unité
  655. ;SET_DRIVE        \1=unité
  656. ;GET_PATH        \1=unité (0=current), PEA\2=adresse de destination
  657. ;SET_PATH        PEA\1=path désiré
  658. ;GET_DTA        renvoie d0=adresse
  659. ;SET_DTA        PEA\1=adresse
  660. ;GET_DTA        d0=adresse
  661.  
  662. ;RESERVE_SCREENS    ~en superviseur~ \1=nb.ecr \2=resolut
  663. ;        + variables : x_max_p,y_max_p,nb_bits_per_pix
  664. ;RESTORE_SCREENS
  665. ;SAVE_PALETTE
  666. ;RESTORE_PALETTE    ~après SAVE_PALETTE~
  667. ;COLOR256        tests colorés en 256 couleurs
  668. ;COLOR        idem en 16
  669. ;ZILOGR:        zilog read : \1=register \2=byte
  670. ;ZILOGW:        zilog write : \1=register \2=byte
  671.  
  672. ;    move.l #'*.*'*256,whato
  673. ;    lea texte,a0        ; 35 chars max.
  674. ;    bsr copy_in2_select
  675. ;    bsr fileselect
  676. ;    tst d4
  677. ;    beq.s annule
  678.