A85: Calculator Power Down


[Prev][Next][Index][Thread]

A85: Calculator Power Down



I'm working on a program that will power down the calculator, but NOT mask
the 200 hz timer interrupts.  I had the following so far, but it still
masks the 200 hz interrupts:

#include "usgard.h"
#include "displib.h"

.org 0
.db "Timer",0
.db 0

;+------
;| Shut Down Calculator
;+------


PowerDown:

    DI

    ld a, 11110101b
    OUT  ($03),A
                ;76543210
    ld a, 00000000
    	 ;   ||||
         ;	 ||++---Low Resistance
		 ;	 ++---- 10 Byte Buffer
    out (4),a

	EX	AF,AF'		; 4B59
	EXX			; 4B5A

    ;ld a, $40		; Doesn't work correctly
    ;out (6),a

	EI

        ld      bc, 0

loopoff:
	HALT

        inc     b
        ld      a, b
        cp      200
        jr      z, incsec

        in a, (3)
        bit 3, a

        jr      nz, loopoff
        jr      TurnOn

incsec:
        ld      b, 0
        inc     c
        jr      loopoff

TurnOn:

   	;DI

        ld  a,  $16                 ; Normal Buffer Mode
        out (4),a

   	ld  a, $41
   	out (6),a

	ld a, 00001011b      ;LCD On
   	out (3),a

   	;EI

        ld      a, b
        LIB_CALL_(DISPLIB,D_A_DEC)
        ld      a, c
        LIB_CALL_(DISPLIB, D_A_DEC)
        call    OTH_PAUSE

   	ret

.end

It works fine, powering the calculator down, but it does not break out of
the HALT until ON is pressed, leading me to believe the timer interrupts
are inactive.

---
Evil Jim
Viva La Mexico
<eviljim@geocities.com>
http://www.geocities.com/TimesSquare/Arcade/8210/
I want to die in my sleep like my Grandfather, not screaming in pain like
the passengers in my car...