home *** CD-ROM | disk | FTP | other *** search
- ;ZCal 82 1.1
- ;By: Ahmed El-Helw
- ;Copyright (C) 1998
- ;ahmedre@bellsouth.net
- ;http://asm8x.home.ml.org
-
- #INCLUDE "CRASH82.INC"
- .DB "ZCal 82- By: ARE",0
-
- string = TEXT_MEM
-
- Init:
- ld a,5 ;4 into A [Wednesday]
- ld (DayStart),a ;Starting Day for Month [The First was Wednesday]
- ld a,2 ;2 into A
- ld (Leap),a ;Leap Year = 5 [28 month Feb. this year, 1998]
- ld a,28 ;28 into A
- ld (FebDays),a ;A into FebDays
- ld a,1 ;Loads Month # into A
-
- ld (Month),a ;Loads A into Month [Starting Month December]
- ld hl,1998 ;Loads Year into HL
- ld (Year),hl ;Loads it into Year #
- jr Start ;Start!
-
- Start:
- ROM_CALL(CLEARLCD)
- ld hl,0
- ld (CURSOR_X),hl
- ld hl,TitleString ;TitleString into HL
- ROM_CALL(D_ZM_STR) ;Send to screen! [Large Text]
- set 3,(iy+$05) ;Text is now white on black
- ld de,8*256+0 ;Loads Coordinates
- ld hl,BlankDay ;String into HL
- call PutText ;Display it!
- ld de,8*256+5 ;Loads Coordinates
- ld hl,Satday ;String into HL
- call PutText ;Display it!
- ld de,8*256+15 ;Loads Coordinates
- ld hl,Monday ;String into HL
- call PutText ;Display it!
- ld de,8*256+30 ;Loads Coordinates
- ld hl,Thuesday ;String into HL
- call PutText ;Display it!
- ld de,8*256+45 ;Loads Coordinates
- ld hl,Wednesday ;String into HL
- call PutText ;Display it!
- ld de,8*256+60 ;Loads Coordinates
- ld hl,Thuesday ;String into HL
- call PutText ;Display it!
- ld de,8*256+75 ;Loads Coordinates
- ld hl,Friday ;String into HL
- call PutText ;Display it!
- ld de,8*256+87 ;Loads Coordinates
- ld hl,Satday ;String into HL
- call PutText ;Display it!
- res 3,(iy+$05) ;Text is now black on white
- jp PutCal
-
- PutCal: ;Routine to Display Calander
- call PutMonth ;Routine to Display Month
- ROM_CALL(D_ZM_STR) ;Put the String on Screen
- call PutYear ;Display the Year
- ld a,(DayStart) ;Starting Day into A
- ld (Spot),a ;A into Spot
- ld a,1 ;Load 1 into a
- ld (Day),a ;Make Day = 1
- ld (Week),a ;Make Week = 1
- jr Loop ;Goto Loop
-
- Loop: ;Loop to Display the Numbers
- ld a,(Spot) ;Spot into A
- cp 1 ;Is it 1?
- jp z,DispSun ;Goto Display Sunday
- cp 2 ;Is it 2?
- jp z,DispMon ;Display Monday
- cp 3 ;Is it 3?
- jp z,DispTue ;Display Tuesday
- cp 4 ;Is it 4?
- jp z,DispWed ;Display Wednesday
- cp 5 ;Is it 5?
- jp z,DispThur ;Display Thursday
- cp 6 ;Is it 6?
- jp z,DispFri ;Display Friday
- cp 7 ;Is it 7?
- jp z,DispSat ;Display Saturday
-
- DispSun:
- call CheckWeek ;Checks week to set
- ld a,1 ;1 into A
- ld (CURSOR_X),a ;A into Column
- ld a,(Day) ;Day into A
- call DispA ;Display A
- jp CheckStatus ;Checks Status of Days
-
- DispMon:
- call CheckWeek ;Checks week to set
- ld a,15 ;15 into A
- ld (CURSOR_X),a ;A into Column
- ld a,(Day) ;Day into A
- call DispA ;Display A
- jp CheckStatus ;Checks Status of Days
-
- DispTue:
- call CheckWeek ;Checks week to set
- ld a,30 ;30 into A
- ld (CURSOR_X),a ;A into Column
- ld a,(Day) ;Day into A
- call DispA ;Display A
- jp CheckStatus ;Checks Status of Days
-
- DispWed:
- call CheckWeek ;Checks week to set
- ld a,45 ;45 into A
- ld (CURSOR_X),a ;A into Column
- ld a,(Day) ;Day into A
- call DispA ;Display A
- jp CheckStatus ;Checks Status of Days
-
- DispThur:
- call CheckWeek ;Checks week to set
- ld a,60 ;60 into A
- ld (CURSOR_X),a ;A into Column
- ld a,(Day) ;Day into A
- call DispA ;Display A
- jp CheckStatus ;Checks Status of Days
-
- DispFri:
- call CheckWeek ;Checks week to set
- ld a,75 ;75 into A
- ld (CURSOR_X),a ;A into Column
- ld a,(Day) ;Day into A
- call DispA ;Display A
- jp CheckStatus ;Checks Status of Days
-
- DispSat:
- call CheckWeek ;Checks week to set
- ld a,87 ;87 into A
- ld (CURSOR_X),a ;A into Column
- ld a,(Day) ;Day into A
- call DispA ;Display A
- jp CheckStatus ;Checks Status of Days
-
- CheckStatus:
- ld a,(TotalDays) ;Total Days into A
- ld b,a
- ld a,(Day) ;Days into A
- sub b
- or a
- jp z,GetKeyLoop ;Goto GetKeyLoop if equal
- jp ContinueLoop ;Otherwise, Continue Loop
-
- ContinueLoop:
- ld a,(Day) ;Day into A
- inc a ;Increase A
- ld (Day),a ;Back into Day
- ld a,(Spot) ;Loads Spot into a
- inc a ;Increase it
- ld (Spot),a ;A into Spot
- cp 8 ;Is it 8
- jp z,NewWeek ;Do a NewWeek
- jp Loop ;Redo Loop
-
- NewWeek:
- ld a,(Week) ;Week into A
- inc a ;Increase it
- ld (Week),a ;A back into Week
- ld a,1 ;1 into A [Sunday]
- ld (Spot),a ;A into Spot
- jp Loop ;Return
-
- GetKeyLoop:
- halt ;Save Energy
- call GET_KEY ;Wait for a key
- cp G_CLEAR ;Is it Clear ?
- ret z ;Return
- cp G_RIGHT ;Is it Right?
- jp z,IncreaseMonth ;Increase the Month!
- cp G_LEFT
- jp z,DecreaseMonth
- cp G_UP ;Is it Up?
- jp z,IncreaseYear ;Increase the Year
- cp G_DOWN ;Is it Down?
- jp z,DecreaseYear ;Decrease the Year
- jp nz,GetKeyLoop ;No Key? Reloop!
-
- IncreaseYear:
- ld a,(DayStart) ;Load DayStart into A
- inc a ;Increase A
- ld (DayStart),a ;A into DayStart
- cp 8 ;Is it 8?
- call z,ResetStart ;Reset to Sunday!
- ld hl,(Year) ;Year into HL
- inc hl ;Increase it
- ld (Year),hl ;HL back into Year
- ld a,28 ;Load 28 into A
- ld (FebDays),a ;Febuary Days as a
- ld a,(Leap) ;Leap into A
- dec a ;Decrease it
- ld (Leap),a ;Load A into Leap
- or a ;Is it 0 ?
- call z,LeapYear ;Call LeapYear
- call ResetVars
- jp Start
-
- DecreaseYear:
- ld a,(DayStart) ;Load DayStart into A
- dec a ;Decrease A
- ld (DayStart),a ;A into DayStart
- cp 0 ;Is it 0?
- call z,ResetSaturday ;Reset to Saturday!
- ld hl,(Year) ;Year into HL
- dec hl ;Decrease it
- ld (Year),hl ;HL back into Year
- ld a,28 ;Load 28 into A
- ld (FebDays),a ;Febuary Days as a
- ld a,(Leap) ;Leap into A
- inc a ;Increase it
- ld (Leap),a ;Load A into Leap
- cp 8 ;Is it 8 ?
- call z,LeapYear ;Call LeapYear
- cp 4 ;Is it 4?
- call z,LeapYear ;Call LeapYear
- call ResetVars
- jp Start
-
- IncreaseMonth:
- ld a,(Spot) ;Day Spot into A
- inc a ;Increase
- ld (DayStart),a ;A into DayStart
- cp 8 ;Is it 8?
- call z,ResetStart ;Reset to Sunday!
- ld a,(Month) ;Month # into A
- inc a ;Increase it
- ld (Month),a ;A into Month
- cp 13 ;Is it 13??
- call z,NewYear ;NewYear!
- call ResetVars
- jp Start ;Goto Start! [Display it!]
-
- ;-------------------------------
- ;|Routines to Decrease the Month
- ;-------------------------------
- DecreaseMonth:
- ld a,(Month) ;Checks the month.. if it is
- cp 3 ;March, your going to Feb
- jp z,GotoFeb ;If it is a 31 day month, your going to a 30 day month..
- cp 5
- jp z,Goto30
- cp 7
- jp z,Goto30
- cp 11
- jp z,Goto30
- cp 8 ;August and July are 30 days, so special loop for them..
- jp z,GotoJul
- cp 1 ;If it is January, your going to switch years, so another
- jp z,GotoDec ;special loop for that...
- cp 2 ;If it is February, we are dealing with a random number of
- jp z,GotoJan ;days, so a special loop for that as well...
-
- ld b,29 ;If not,then we are going to a 31 day month.. Loop 29x to get
- Dec3031Days: ;to the beginning of the month...
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz Dec3031Days
-
- ld b,31 ;Then loop 31x to get to the beginning of the previous month..
- Dec31Days:
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz Dec31Days
- ld a,(Spot)
- ld (DayStart),a
- ld a,(Month)
- dec a
- ld (Month),a
- or a
- call z,OldYear
- call ResetVars
- jp Start
-
- ResDecSat: ;If spot is 0, this means that
- ld a,7 ;we are really on a Saturday..
- ld (Spot),a ;so we make it Saturday.
- ret
-
- Goto30:
- ld b,30
- Dec3130Days:
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz Dec3130Days
-
- ld b,30
- Dec30Days:
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz Dec30Days
-
- ld a,(Spot)
- ld (DayStart),a
- ld a,(Month)
- dec a
- ld (Month),a
- call ResetVars
- jp Start
-
- GotoFeb:
- ld b,30
- DecMarDays:
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz DecMarDays
-
- ld a,(FebDays)
- ld b,a
-
- DecFebDays:
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz DecFebDays
- ld a,(Spot)
- ld (DayStart),a
- ld a,(Month)
- dec a
- ld (Month),a
- call ResetVars
- jp Start
-
- GotoJul:
- ld b,31
- DecJulDays:
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz DecJulDays
-
- ld a,31
- ld b,a
-
- JulDays:
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz JulDays
- ld a,(Spot)
- inc a
- ld (DayStart),a
- ld a,(Month)
- dec a
- ld (Month),a
- call ResetVars
- jp Start
-
- GotoDec:
- ld b,30
- DecJanDays:
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz DecJanDays
-
- ld b,31
- DecDecDays:
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz DecDecDays
- ld a,(Spot)
- ld (DayStart),a
- ld a,12
- ld (Month),a
- call OldYear
- jp Start
-
- GotoJan:
- ld a,(FebDays)
- ld b,a
- DecFDays:
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz DecFDays
-
- ld b,31
-
- DectoJanDays:
- ld a,(Spot)
- dec a
- ld (Spot),a
- or a
- call z,ResDecSat
- djnz DectoJanDays
- ld a,(Spot)
- inc a
- ld (DayStart),a
- ld a,(Month)
- dec a
- ld (Month),a
- call ResetVars
- jp Start
-
- OldYear:
- ld hl,(Year)
- dec hl
- ld (Year),hl
- ld a,(Leap) ;Leap into A
- inc a ;Increase it
- ld (Leap),a ;Load A into Leap
- cp 8 ;Is it 8 ?
- call z,LeapYear ;Call LeapYear
- cp 4 ;Is it 4?
- call z,LeapYear ;Call LeapYear
- ret
-
- ResetStart:
- ld a,1 ;Loads 1 into A
- ld (DayStart),a ;A into DayStart [Sunday]
- ret ;Return
-
- ResetSaturday:
- ld a,7 ;Loads 7 into A
- ld (DayStart),a ;A into DayStart [Saturday]
- ret ;Return
-
- NewYear:
- ld a,1 ;Loads 1 into A
- ld (Month),a ;A into Month [January]
- ld hl,(Year) ;Year into HL
- inc hl ;Increase it
- ld (Year),hl ;HL into Year
- ld a,(Leap) ;Leap into A
- dec a ;Decrease it
- ld (Leap),a ;Back into Leap
- cp 0 ;Is it 0?
- jp z,LeapYear ;LeapYear it is
- ld a,28 ;Loads 28 into A
- ld (FebDays),a ;A into FebDays
- ret ;return
-
- LeapYear: ;Loop to find out if the year is 100x
- ld hl,(Year) ;Loads Year into HL
- ld (TestYear),hl ;Loads HL into TestYear
- ld b,60 ;Loads 10 into b, starting a loop...
-
- LeapLoop:
- ld hl,(TestYear) ;Load the Test Year into HL
- ld de,0 ;We want to check if it is 0
- call CP_HL_DE ;So we check...
- jp z,Test400x ;if it is 0, then it is 100x, so test 400x
- ld hl,(TestYear) ;if not, then keep going...
- ld de,-100 ;Load -100 into bc
- add hl,de ;Add it w/the year [aka TestYear-500]
- ld (TestYear),hl ;Loads that into Year
- djnz LeapLoop ;Reloops until b = 0
- ;---------------Real Leap Year!--------------------
- RLY: ;Real Leap Year!
- ld a,29 ;Loads 29 into A
- ld (FebDays),a ;Loads A into FebDays
- ld a,4 ;Loads 4 into A
- ld (Leap),a ;A into Leap [LeapYear]
- ret ;return
-
- Test400x:
- ld hl,(Year) ;Loads Year into HL
- ld (TestYear),hl ;Loads HL into TestYear
- ld b,60 ;Loads 10 into b, starting a loop...
-
- LeapLoop2:
- ld hl,(TestYear) ;Load the Test Year into HL
- ld de,0 ;We want to check if it is 0
- call CP_HL_DE ;So we check...
- jp z,RLY ;if it is 0, then it is 400x, so leap year
- ld hl,(TestYear) ;if not, then keep going...
- ld de,-400 ;Load -100 into bc
- add hl,de ;Add it w/the year [aka TestYear-400]
- ld (TestYear),hl ;Loads that into Year
- djnz LeapLoop2 ;Reloops until b = 0
-
- NotReal: ;Not REALLY a Leap Year...
- ld a,4 ;Loads 4 into A
- ld (Leap),a ;Reset LeapDays
- ret ;Return
-
- ResetVars:
- xor a ;Load 0 into a
- ld (Week),a ;A into Week
- ld (Day),a ;A into Day
- ld (Spot),a ;A into Spot
- ret
-
- CheckWeek:
- ld a,(Week) ;Loads the week into A
- cp 1 ;Is it 1
- jp z,Week1 ;Then set Week1 Coords
- cp 2 ;Is it 2
- jp z,Week2 ;Then set Week2 Coords
- cp 3 ;Is it 3
- jp z,Week3 ;Then set Week3 Coords
- cp 4 ;Is it 4
- jp z,Week4 ;Then set Week4 Coords
- cp 5 ;Is it 5
- jp z,Week5 ;Set Week5 Coords
- jp nz,Week6 ;Otherwise .. Week6
-
- Week1:
- ld a,15 ;Load into A
- ld (CURSOR_Y),a ;Set a as PenRow
- ret ;Return
-
- Week2:
- ld a,22 ;Load into A
- ld (CURSOR_Y),a ;Set a as PenRow
- ret ;Return
-
- Week3:
- ld a,29 ;Load into A
- ld (CURSOR_Y),a ;Set a as PenRow
- ret ;Return
-
- Week4:
- ld a,36 ;Load into A
- ld (CURSOR_Y),a ;Set a as PenRow
- ret ;Return
-
- Week5:
- ld a,43 ;Load into A
- ld (CURSOR_Y),a ;Set a as PenRow
- ret ;Return
-
- Week6:
- ld a,50 ;Loads into A
- ld (CURSOR_Y),a ;Set a as PenRow
- ret
-
-
- PutMonth:
- ld a,(Month) ;Loads Month # into A
- cp 1 ;If it is 1
- jp z,Month1 ;Goto Month1 [January]
- cp 2 ;Is it two?
- jp z,Month2 ;Goto Month2 [Febuary]
- cp 3 ;Is it 3?
- jp z,Month3 ;Goto Month3 [March]
- cp 4 ;Is it 4
- jp z,Month4 ;Goto Month 4
- cp 5 ;Is it 5
- jp z,Month5 ;Goto Month5
- cp 6 ;Is it 6
- jp z,Month6 ;Goto Month 6
- cp 7 ;Is it 7
- jp z,Month7 ;Goto Month7
- cp 8 ;Is it 8
- jp z,Month8 ;Goto Month 8
- cp 9 ;Is it 9
- jp z,Month9 ;Goto Month 9
- cp 10 ;Is it 10
- jp z,Month10 ;Goto Month10
- cp 11 ;Is it 11
- jp z,Month11 ;Goto Month11
- jp nz,Month12 ;Otherwise, it has to be 12, so goto Month12
-
- Month1: ;Month1 Label [January]
- ld a,31 ;31 into A
- ld (TotalDays),a ;A -> Total Days
- call SetText ;Put coordinates for text
- ld hl,January ;String into HL
- ret ;Return to Call
-
- Month2: ;Month2 Label [February]
- ld a,(FebDays) ;February Days into A
- ld (TotalDays),a ;A => Total Days
- call SetText ;Put coordinates for text
- ld hl,Febuary ;String into HL
- ret ;Return to Call
-
-
- Month3: ;Month3 Label [March]
- ld a,31 ;31 into A
- ld (TotalDays),a ;A -> Total Days
- call SetText ;Put coordinates for text
- ld hl,March ;String into HL
- ret ;Return to Call
-
- Month4: ;Month4 Label [April]
- ld a,30 ;30 into A
- ld (TotalDays),a ;A -> Total Days
- call SetText ;Put coordinates for text
- ld hl,April ;String into HL
- ret ;Return to Call
-
- Month5: ;Month5 Label [May]
- ld a,31 ;31 into A
- ld (TotalDays),a ;A -> Total Days
- call SetText ;Put coordinates for text
- ld hl,May ;String into HL
- ret ;Return to Call
-
- Month6: ;Month6 Label [June]
- ld a,30 ;30 into A
- ld (TotalDays),a ;A -> Total Days
- call SetText ;Put coordinates for text
- ld hl,June ;String into HL
- ret ;Return to Call
-
- Month7: ;Month7 Label [July]
- ld a,31 ;31 into A
- ld (TotalDays),a ;A -> Total Days
- call SetText ;Put coordinates for text
- ld hl,July ;String into HL
- ret ;Return to Call
-
- Month8: ;Month8 Label [August]
- ld a,31 ;31 into A
- ld (TotalDays),a ;A -> Total Days
- call SetText ;Put coordinates for text
- ld hl,August ;String into HL
- ret ;Return to Call
-
- Month9: ;Month9 Label [September]
- ld a,30 ;30 into A
- ld (TotalDays),a ;A -> Total Days
- call SetText ;Put coordinates for text
- ld hl,September ;String into HL
- ret ;Return to Call
-
- Month10: ;Month1 Label [October]
- ld a,31 ;31 into A
- ld (TotalDays),a ;A -> Total Days
- call SetText ;Put coordinates for text
- ld hl,October ;String into HL
- ret ;Return to Call
-
- Month11: ;Month11 Label [November]
- ld a,30 ;30 into A
- ld (TotalDays),a ;A -> Total Days
- call SetText ;Put coordinates for text
- ld hl,November ;String into HL
- ret ;Return to Call
-
- Month12: ;Month12 Label [December]
- ld a,31 ;31 into A
- ld (TotalDays),a ;A -> Total Days
- call SetText ;Put coordinates for text
- ld hl,December ;String into HL
- ret ;Return to Call
-
- SetText:
- ld hl,57*256+20 ;Set Coordinates
- ld (CURSOR_X),hl ;Into PenCol
- ret ;Return
-
- PutYear:
- ld hl,57*256+60 ;Set Coordinates
- ld (CURSOR_X),hl ;Into PenCol
- ld hl,(Year) ;Load Year # into HL
- call DispHL ;Display It!
- res 3,(iy+$05)
- ret
-
- PutText:
- ld (CURSOR_X),de
- ROM_CALL(D_ZM_STR)
- ret
-
- ;-----------------dispA and HL -----------------------
- DispA:
- ld h,0
- ld l,a
-
- DispHL:
- push de
- push hl
- ld de,string+5
- xor a
- ld (de),a
- Repeat:
- call UNPACK_HL
- add a,'0'
- dec de
- ld (de),a
- ld a,h
- or l
- jr nz,Repeat
- ex de,hl
- ROM_CALL(D_ZM_STR)
- pop hl
- pop de
- ret
- ;---------------------------------------------------------
-
- TitleString: .db "Calendar 82z - By: Ahmed E",0
- BlankDay: .db " ",0
-
- Satday: .db "S ",0
- Monday: .db "M ",0
- Thuesday: .db "T ",0
- Wednesday: .db "W ",0
- Friday: .db "F ",0
-
- January: .db "January",0
- Febuary: .db "February",0
- March: .db "March",0
- April: .db "April",0
- May: .db "May",0
- June: .db "June",0
- July: .db "July",0
- August: .db "August",0
- September: .db "September",0
- October: .db "October",0
- November: .db "November",0
- December: .db "December",0
-
- ;-----------------------Variables-------------------------
- DayStart: .db 0
- Month: .db 0
- Week: .db 0
- Spot: .db 0
- TotalDays: .db 0
- Day: .db 0
- Leap: .db 0
- FebDays: .db 0
- Year: .db 0,0
- TestYear: .db 0,0
- ;---------------------------------------------------------
-
- .end ;Tell TASM it is all over
- END ;Tell TASM it is all over
-
-