home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 86 / asm / source / aprilfools.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  5.1 KB  |  158 lines

  1. people have been requesting the source for the april fool's joke so here it
  2. is.  i'm sure i could have optimized, etc. but i wanted to get it to you
  3. before when you needed to use it :)  probably look at it in
  4. courier/monospaced font or notepad or something for best clarity        kirk
  5.  
  6. === begin source code
  7.  
  8. #include "asm86.h"
  9. #include "ram86.inc"
  10. #include "ti86abs.inc"
  11. #include "ti86asm.inc"
  12. #include "ti86ops.inc"
  13. .org _asm_exec_ram
  14. Start:
  15.    ld hl,op_info-1      ;this sees if (sqrt)KEY already exists
  16.    rst 20h
  17.    call _findsym
  18.    jr c,Install
  19.    call _delvar         ;if so, delete it :)
  20. Install:
  21.    ld hl,code_end-code  ;hl = size of program
  22.    push hl              ;we need this value again, so save it
  23.    call $474f           ;creates program (name already was in OP1)
  24.    ld a,b
  25.    ex de,hl
  26.    call $4c3f
  27.    call _SET_ABS_DEST_ADDR
  28.    xor a
  29.    pop hl               ;get back our saved value
  30.    call _SET_MM_NUM_BYTES
  31.    ld hl,code           ;point to the code
  32.    call _SET_ABS_SRC_ADDR
  33.    call _mm_ldir        ;copy the program to (sqrt)KEY
  34.    res 0,(iy+$25)       ;set the user-defined flag
  35.    set 6,(iy+$24)       ;enable (sqrt)KEY
  36.    jp $409c             ;return
  37. op_info:
  38.    .db $4,$10
  39.    .db "KEY",0
  40. code:
  41.    .db $8e,$28
  42.    call $479f           ;a call used in TI's demo program
  43.    ld a,(_asm_reg_a)    ;get saved value of A - its the key code pressed
  44.    push af              ;save this value
  45.    bit 0,(iy+$20)
  46.    jr nz,code_exit      ;i dunno but i think it must be there
  47.    ld a,(_CXCURAPP)     ;load the current screen of the calculator
  48.    cp $20               ;if they're not looking at the RAM...
  49.    jr nz,code_exit      ;then skip everything
  50.    pop af               ;get our getkey value back
  51.    push af              ;then save it again
  52.    cp K_MORE            ;if they aren't pushing MORE at this screen
  53.    jr nz,code_exit      ;then skip everything
  54.    bit 0,(iy+$25)       ;if it's already enabled, disable it
  55.    jr nz,is_going
  56.    set 0,(iy+$25)       ;otherwise, enable it
  57.    call _clrScrn        ;clear the screen
  58.    call _homeup         ;and display the message
  59.    ld hl,the_message
  60.    call _puts
  61.    call _homeup
  62.    call  $4ab5          ;this copies _textShadow to _cmdShadow i think
  63.    jp $409C             ;return
  64. is_going:
  65.    res 0,(iy+$25)       ;reset the user flag
  66.    ld a,$1F             ;something extra not in the release version
  67.    ld ($C008),a         ;this turns the contrast all the way down but tells
  68.    xor a                ;the 86 that it's all the way up. the effect is that
  69.    out (2),a            ;they must turn the contrast down to turn it up :)
  70. code_exit:
  71.    pop af               ;pop our saved getkey
  72.    bit 0,(iy+$25)       ;look at the user flag
  73.    jr z,code_done       ;if not set, go to the ending
  74.    ld hl,key_table      ;point to the translator table
  75.    ld d,0               ;de = the key pressed
  76.    ld e,a
  77.    add hl,de            ;get offset into table
  78.    ld a,(hl)            ;and get a byte
  79. code_done:
  80.    cp a                 ;if the zero flag is set upon returning from
  81.                         ;(sqrt)KEY then it takes the value in A and makes
  82.                         ;that into the key that was pressed. if the not zero
  83.                         ;flag is set, then i think (i haven't tested this)
  84.                         ;that the value in A is taken as the key that was
  85.                         ;pressed also. however - when the zero flag is set,
  86.                         ;the key is a code associated with _getky (the
  87.                         ;one that doesn't loop). when the not zero flag is
  88.                         ;set, the key is a code associated with _getkey (the
  89.                         ;one that does loop and also saves energy).
  90.    ret                  ;return - could also use jp $409C if i felt like it
  91. :)
  92. the_message = $ - code + $D746
  93.             ;123456789012345678901
  94.         .db " Hah! Did you forget "
  95.         .db "about April Fool",39,"s???"
  96.         .db "  I rearranged your  "
  97.         .db "keyboard for you. You"
  98.         .db "can eliminate this by"
  99.         .db " pushing MORE at the "
  100.         .db "memory check screen!!",0
  101. ;this is the table for the keyremapping
  102. key_table = $ - code + $D746
  103.         .db $00
  104.         .db $13
  105.         .db $04
  106.         .db $09
  107.         .db $15
  108.                 .db 0,0,0,0
  109.         .db $14
  110.         .db $02
  111.         .db $22
  112.         .db $27
  113.         .db $16
  114.         .db $1F
  115.         .db $19
  116.                 .db 0
  117.         .db $0C
  118.         .db $0D
  119.         .db $17
  120.         .db $1C
  121.         .db $01
  122.         .db $0A
  123.         .db $0B
  124.                 .db 0
  125.         .db $21
  126.         .db $33
  127.         .db $26
  128.         .db $34
  129.         .db $25
  130.         .db $1D
  131.         .db $23
  132.         .db $1A
  133.         .db $1B
  134.         .db $35
  135.         .db $1E
  136.         .db $0E
  137.         .db $36
  138.         .db $2C
  139.         .db $32
  140.         .db $37
  141.                 .db 0
  142.         .db $24
  143.         .db $20
  144.         .db $2D
  145.         .db $28
  146.         .db $2A
  147.         .db $12
  148.         .db $38
  149.         .db $2E
  150.         .db $2B
  151.         .db $0F
  152.         .db $11
  153.         .db $2F
  154.         .db $30
  155.         .db $31
  156.         .db $03
  157. code_end:
  158. .end