home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 408.lha / FASTPAL / FASTPAL.ASM < prev    next >
Assembly Source File  |  1990-09-02  |  6KB  |  218 lines

  1. ;
  2. ;      PAL/NTSC Switch    by Ed Mackey
  3. ;       "on the fly"         440 Louella Ave.
  4. ;                            Wayne, PA 19087
  5.  
  6. ;  This program is supposed to let you change between PAL and NTSC
  7. ;  modes after your computer is already booted up.  Unfortunately,
  8. ;  the length of the WorkBench screen is not affected, but the display
  9. ;  (number of scan lines) and timers are!
  10.  
  11. ;  You must have a "Fatter" Agnus for this program to work.  If you
  12. ;  run this program and nothing happens, you probably only have the
  13. ;  "Fat" Agnus.  If you KNOW you have the "Fatter" Agnus and this
  14. ;  program STILL doesn't do anything, well, you got your money's
  15. ;  worth for a free program.  I hope this happens to nobody, and I
  16. ;  don't know why it would.
  17.  
  18. ;  I'm sorry this program isn't a Super-Flexible-User-Friendly
  19. ;  work of organized programming, but it was made in all of
  20. ;  15 minutes.   ;->
  21.  
  22. ;  Here is the source code, assembled with Assempro by Abacus.
  23. ;  This is Public Domain.  Please don't change the credits, though.
  24.  
  25.        Include 'includes:IncludeMe'
  26.        Include 'includes:intuition.offsets'
  27.  
  28.        ILABEL 'Includes:Amiga.L'
  29.  
  30.        INIT_AMIGA   ;Run me from WB!
  31.  
  32.        bsr     run
  33.  
  34.        EXIT_AMIGA
  35.  
  36. ; Special thanks to Andy Hook for providing the following address
  37. ; in the source code to his PD version of Tetris:
  38.  
  39. PalSwitch = $DFF1DC    ;Usage:  MOVE.B #NTSC,PALSWITCH
  40. NTSC      = 2          ;   or:  MOVE.B #PAL ,PALSWITCH
  41. PAL       = 32
  42.  
  43. ; This program would not exist without it!  Thanks!
  44.  
  45. ; (AmigaBASIC version of the above:
  46. ;    PalSwitch& = 14676444
  47. ;    NTSC% = 2 : PAL% = 32
  48. ;    POKE PALSWITCH&,PAL%    'For PAL
  49. ;    POKE PALSWITCH&,NTSC%   'For NTSC (duh...)
  50. ;  but do NOT ever PEEK(PALSWITCH&) unless you want to see funny
  51. ;  lines that force you to reboot!)
  52.  
  53. run:
  54.        bsr     openint      ;open intuition.library
  55.        beq     IntKicked    ;uh-oh.  Where's intuition?!?!
  56.        bsr     windopen     ;make my window.
  57.        beq     WindKicked
  58.        bsr     changetitle
  59.        move.b  #NTSC,CurrentMode
  60.        move.b  CurrentMode,PalSwitch   ;At start, default to NTSC.
  61.        bsr     TellUser
  62. loop:
  63.        move.l  EBase,a6
  64.        move.l  windowhd,a0
  65.        move.l  86(a0),a0
  66.        jsr     _LVOWaitPort(a6)  ;wait for a gadget.
  67.        move.l  #0,d7
  68. loop2:
  69.        move.l  windowhd,a0
  70.        move.l  86(a0),a0
  71.        jsr     _LVOGetMsg(a6)    ;read in the gadget message.
  72.        tst.l   d0
  73.        bne     ReadMsg           ;decode it
  74.        cmp.l   #0,d7
  75.        beq     loop              ;no message?
  76.        cmp.l   #2,d7
  77.        beq     GoForIt           ;Custom gadget: Switch modes!
  78. ende:
  79.        bsr     windclose         ;Close Gadget: Remove window & exit
  80. WindKicked:
  81.        bsr     closeint
  82. IntKicked:
  83.        rts   ;that's all folks!
  84. ReadMsg:
  85.        move.l  d0,a5
  86.        move.l  20(a5),d6
  87.        move.l  d6,d0             ;Decode this IDCMP message.
  88.        and.l   #$200,d0          ;Was it the Close gadget?
  89.        cmp.l   #0,d0
  90.        beq     NotClose          ;Nope.
  91.        move.l  #1,d7
  92.        bra     Reply
  93. NotClose:
  94.        move.l  d6,d0
  95.        and.l   #$40,d0           ;How 'bout MY gadget?
  96.        tst.l   d0
  97.        beq     Reply
  98.        move.l  28(a5),d0         ;Aha!!  Here it is!
  99.        cmp.l   #gadget1,d0       ;Check WHICH custom gadget it was.
  100.        bne     Reply             ;(this is obviously not needed in
  101.        move.l  #2,d7             ;this case, with only one custom gad,
  102. Reply:                           ;but it's good planning ahead!)
  103.        move.l  a5,a1
  104.        move.l  EBase,a6
  105.        jsr     _LVOReplyMsg(a6)  ;ReplyMsg() to ALL messages!
  106.        bra     Loop2
  107. GoForIt:                      ;The actual switcheroo!
  108.        clr     d0
  109.        move.b  #NTSC+PAL,d0   ;Put their sum in d0...
  110.        clr     d1
  111.        move.b  CurrentMode,d1
  112.        sub     d1,d0          ;...then subtract one to get the other!
  113.        move.b  d0,CurrentMode
  114.        move.b  d0,PalSwitch   ;Send it to the hardware...
  115.        bsr     TellUser
  116.        bra     Loop
  117. TellUser:                     ;Tell user what mode he's in.
  118.        move.l  windowhd,a0
  119.        move.l  50(a0),a0      ;find RastPort
  120.        clr.l   d0
  121.        clr.l   d1
  122.        lea     NTSCtext,a1
  123.        cmp.b   #NTSC,CurrentMode
  124.        beq     Ok
  125.        lea     PALtext,a1
  126. Ok:    move.l  intbase,a6
  127.        jsr     _LVOPrintIText(a6)  ;output text.
  128.        rts
  129. openint:
  130.        move.l  EBase,a6
  131.        lea     intname,a1
  132.        move.l  #0,d0
  133.        jsr     _LVOopenlibrary(a6)  ;open intuition.library
  134.        move.l  d0,intbase
  135.        tst.l   d0
  136.        rts
  137. closeint:
  138.        move.l  EBase,a6
  139.        move.l  intbase,a1
  140.        jsr     _LVOcloselibrary(a6) ;close intuition.library
  141.        rts
  142. windopen:
  143.        move.l  intbase,a6
  144.        lea     windowdef,a0
  145.        jsr     _LVOopenwindow(a6)   ;make my window.
  146.        move.l  d0,windowhd
  147.        tst.l   d0
  148.        rts
  149. changetitle:
  150.        move.l  d0,a0
  151.        lea     windname,a1
  152.        lea     tite1,a2
  153.        jsr     _LVOSetWindowTitles(a6)  ;Change Screen title bar.
  154.        rts
  155. windclose:
  156.        move.l  intbase,a6
  157.        move.l  windowhd,a0
  158.        jsr     _LVOclosewindow(a6)  ;close my window.
  159.        rts
  160.  
  161.        DATA   ;data section!
  162. windowdef:
  163.        dc.w    100,50,142,30
  164.        dc.b    3,1
  165.        dc.l    $240,$100e,gadget1,0,windname
  166.        dc.l    0,0
  167.        dc.w    0,0,0,0,1
  168. tite1:
  169.        dc.b    'PAL/NTSC Switch "on the fly"     by Ed Mackey        :-)',0
  170.        align
  171. windname:
  172.        dc.b    'FASTPAL',0
  173.        align
  174. gadget1:
  175.        dc.l    0
  176.        dc.w    75,14,57,11,0,1,1
  177.        dc.l    boarder,0,gotext,0,0
  178.        dc.w    8  ;ID
  179.        dc.l    0
  180. gotext:
  181.        dc.b    1,0,1,0
  182.        dc.w    1,2  ;x,y
  183.        dc.l    0,goascii,0
  184. NTSCtext:
  185.        dc.b    1,0,1,0
  186.        dc.w    10,16
  187.        dc.l    0,NTSCascii,0
  188. PALtext:
  189.        dc.b    3,0,1,0
  190.        dc.w    10,16
  191.        dc.l    0,PALascii,0
  192. goascii:
  193.        dc.b    'CHANGE!',0
  194.        align
  195. NTSCascii:
  196.        dc.b    'NTSC',0
  197.        align
  198. PALascii:
  199.        dc.b    'PAL ',0
  200.        align
  201. boarder:
  202.        dc.w    0,0
  203.        dc.b    3,0,0,5
  204.        dc.l    ptlist,0
  205. ptlist:
  206.        dc.w    -1,-1,  57,-1,  57,11,  -1,11,  -1,-1
  207. intname:
  208.        dc.b    'intuition.library',0
  209.        align
  210.        BSS
  211. windowhd:
  212.        ds.l    1
  213. CurrentMode:
  214.        ds.w    1
  215. intbase:
  216.        ds.l    1
  217.        END
  218.