Friday, March 4, 2016

Trying to figure out how the buzzer works

I wondered how the buzzer works, and I found some code that looks relevant.

The buzzer is on PC7 which is the C01 counter output.

If I send a $07 bel character the ap2000 will beep, executing the routine at $1057.


debugger commands to make my trace log:

WP 8000,1F00,w,1,{tracelog " WRITE addr=%x data=%x \n", wpaddr,wpdata;g}
WP 8000,1F00,r,1,{tracelog " READ addr=%x data=%x \n", wpaddr,wpdata;g}
WP FF00,100,w,1,{tracelog " WRITE addr=%x data=%x \n", wpaddr,wpdata;g}
WP FF00,100,r,1,{tracelog " READ addr=%x data=%x \n", wpaddr,wpdata;g}

WP 0000,8000,r,1,{tracelog " READROM addr=%x data=%x \n", wpaddr,wpdata;g}

trace TRACEbeep.TXT,0,{tracelog "A=%02X EA=%04X HL=%04X DE=%04X BC=%04X SKIP=%1X  |  ",a,ea,hl,de,bc,(psw&0x20)!=0}




    223 A=00 EA=9000 HL=13DA DE=8013 BC=FB00 SKIP=0  |  135C: ACI     H,$00
    224 A=00 EA=9000 HL=13DA DE=8013 BC=FB00 SKIP=0  |  135F: LDEAX   (HL)
    225  READROM addr=13DA data=57 
    226  READROM addr=13DB data=10 
    227 A=00 EA=1057 HL=13DA DE=8013 BC=FB00 SKIP=0  |  1361: JEA     
    228 A=00 EA=1057 HL=13DA DE=8013 BC=FB00 SKIP=0  |  1057: LXI     HL,$0000
    229 A=00 EA=1057 HL=0000 DE=8013 BC=FB00 SKIP=0  |  105A: ORIW    VV:10,$04
    230  READ addr=9810 data=0 
    231  WRITE addr=9810 data=4 
    232 A=00 EA=1057 HL=0000 DE=8013 BC=FB00 SKIP=0  |  105D: PUSH    HL
    233 A=00 EA=1057 HL=0000 DE=8013 BC=FB00 SKIP=0  |  105E: CALL    $7BB1
    234 A=00 EA=1057 HL=0000 DE=8013 BC=FB00 SKIP=0  |  7BB1: ONIW    VV:0F,$C0
    235  READ addr=980F data=0 
    236 A=00 EA=1057 HL=0000 DE=8013 BC=FB00 SKIP=0  |  7BB4: OFFIW   VV:01,$30
    237  READ addr=9801 data=8 
    238 A=00 EA=1057 HL=0000 DE=8013 BC=FB00 SKIP=1  |  7BB7: JR      $7BA9
    239 A=00 EA=1057 HL=0000 DE=8013 BC=FB00 SKIP=0  |  7BB8: RET     
    240 A=00 EA=1057 HL=0000 DE=8013 BC=FB00 SKIP=0  |  1061: POP     HL
    241 A=00 EA=1057 HL=0000 DE=8013 BC=FB00 SKIP=0  |  1062: DMOV    EA,HL
    242 A=00 EA=0000 HL=0000 DE=8013 BC=FB00 SKIP=0  |  1063: DMOV    BC,EA
    243 A=00 EA=0000 HL=0000 DE=8013 BC=0000 SKIP=0  |  1064: PUSH    BC
    244 A=00 EA=0000 HL=0000 DE=8013 BC=0000 SKIP=0  |  1065: PUSH    BC
    245 A=00 EA=0000 HL=0000 DE=8013 BC=0000 SKIP=0  |  1066: CALL    $1084
    246 A=00 EA=0000 HL=0000 DE=8013 BC=0000 SKIP=0  |  1084: MVI     A,$00
    247 A=00 EA=0000 HL=0000 DE=8013 BC=0000 SKIP=0  |  1086: MOV     ETMM,A
    248 A=00 EA=0000 HL=0000 DE=8013 BC=0000 SKIP=0  |  1088: MVI     EOM,$B0
    249 A=00 EA=0000 HL=0000 DE=8013 BC=0000 SKIP=0  |  108B: LXI     EA,$008C
    250 A=00 EA=008C HL=0000 DE=8013 BC=0000 SKIP=0  |  108E: DMOV    ETM1,EA
    251 A=00 EA=008C HL=0000 DE=8013 BC=0000 SKIP=0  |  1090: MVI     A,$0C
    252 A=0C EA=008C HL=0000 DE=8013 BC=0000 SKIP=0  |  1092: MOV     ETMM,A
    253 A=0C EA=008C HL=0000 DE=8013 BC=0000 SKIP=0  |  1094: MVI     C,$3C
    254 A=0C EA=008C HL=0000 DE=8013 BC=003C SKIP=0  |  1096: CALT    ($0080)
  
...

    341 
    342    (loops for 15827 instructions)
    343 
    344 A=00 EA=0001 HL=0000 DE=8013 BC=FFFF SKIP=0  |  0030: JR      $003D
    345 A=00 EA=0001 HL=0000 DE=8013 BC=FFFF SKIP=0  |  003D: POP     BC
    346 A=00 EA=0001 HL=0000 DE=8013 BC=003C SKIP=0  |  003E: POP     VA
    347 A=0C EA=0001 HL=0000 DE=8013 BC=003C SKIP=0  |  003F: POP     EA
    348 A=0C EA=008C HL=0000 DE=8013 BC=003C SKIP=0  |  0040: RET     
    349 A=0C EA=008C HL=0000 DE=8013 BC=003C SKIP=0  |  1097: MVI     EOM,$99
    350 A=0C EA=008C HL=0000 DE=8013 BC=003C SKIP=0  |  109A: RET  

the action looks to happen with putting EOM=B0, ETM1=8C AND ETMM=0C

to shut it off it puts EOM=99

so for kicks if you run the ap2000 in the debugger and the ap2000 is waiting for input you can make it beep with the following debugger command line:

etm1=8c;eom=b0;etmm=0c

and to shut it off

eom=99

before you do this, you may want to turn your speakers down, it's really a terrible sound. heh heh

No comments:

Post a Comment