• R/O
  • SSH
  • HTTPS

oricsdk: Commit


Commit MetaInfo

Revision1579 (tree)
Time2022-03-12 22:30:00
Authordbug

Log Message

The Hobbit Improved - Version 1.6
- Added Thror's map as well as a credit picture to the intro, with two new display effects
- Added a menu to toggle the sound ON/OFF
- Added a menu to allow the player to start the original version of the game
- Fixed the brief flash of white corruption appearing when the game starts by clearing the entire video memory area

Change Summary

Incremental Difference

--- users/dbug/UpgradeTime/TheHobbit/common.h (nonexistent)
+++ users/dbug/UpgradeTime/TheHobbit/common.h (revision 1579)
@@ -0,0 +1,21 @@
1+;
2+; These elements are shared between the intro and the game itself
3+;
4+#define PLAY_MUSIC // What the name says: When commented out, the music will not start until you press [S]
5+
6+;
7+; Hardware registers
8+;
9+#define VIA_1 $30f
10+#define VIA_2 $30c
11+
12+;
13+; System/ROM relevant addresses
14+;
15+#define BASIC_KEY $2df ; Latest key from keyboard, bit 7 set if valid
16+
17+;
18+; Communication between the intro and the game passes through the very last bytes of RAM before the ROM
19+;
20+#define FlagPlayImproved $bffe ; If zero, will play the non modified original version
21+#define FlagPlayMusic $bfff ; If zero, will not have any sound or music (only impact the intros so far)
--- users/dbug/UpgradeTime/TheHobbit/intro.s (revision 1578)
+++ users/dbug/UpgradeTime/TheHobbit/intro.s (revision 1579)
@@ -1,13 +1,8 @@
11 ;
22 ; This intro is still heavy work in progress, with bits of code ripped out from "MymPlayer" and "Pushing The Enveloppe"
33 ;
4-#define VIA_1 $30f
5-#define VIA_2 $30c
4+#include "common.h"
65
7-#define BASIC_KEY $2df ; Latest key from keyboard, bit 7 set if valid
8-
9-#define PLAY_MUSIC
10-
116 .zero
127
138 *= $50
@@ -14,8 +9,14 @@
149
1510 tmp0 .dsb 2
1611 tmp1 .dsb 2
12+tmp2 .dsb 2
13+tmp3 .dsb 2
14+tmp4 .dsb 2
15+tmp5 .dsb 2
16+tmp6 .dsb 2
17+tmp7 .dsb 2
1718
18-pos_y .dsb 1
19+should_quit .dsb 1
1920
2021 _DecodedByte .dsb 1 ; Byte being currently decoded from the MYM stream
2122 _DecodeBitCounter .dsb 1 ; Number of bits we can read in the current byte
@@ -41,18 +42,82 @@
4142
4243 _Main
4344 .(
45+ lda #0
46+ sta should_quit
47+
48+#ifdef PLAY_MUSIC
49+ lda #MessageON-MessageOFF
50+#else
51+ lda 0
52+#endif
53+ sta FlagPlayMusic
54+
55+ lda #MessageImproved-MessageOriginal
56+ sta FlagPlayImproved
57+
4458 jsr StartMusic
4559 jsr SwitchToHires
60+
61+ jsr PrintMessages
62+
63+loop_attract_mode
64+ ; Show the title picture with Smaug the dragon
65+ lda #<_TitlePicture-1
66+ ldx #>_TitlePicture-1
4667 jsr _InitTransitionData
68+
4769 jsr StartPictureUnroll
48-loop
49- jsr _VSync
70+loop_show_title
5071 jsr PictureUnrollFrame
51- jsr _VSync
72+ jsr DelayBetweenFrames
73+ bne end_attract_mode
5274
53- lda BASIC_KEY ; Key
54- bpl loop
75+ lda _TransitionDone
76+ beq loop_show_title
5577
78+ ; Wait a bit
79+ jsr DelayBetweenPictures
80+ bne end_attract_mode
81+
82+ ; Show Thror's map picture
83+ lda #<_MapPicture-1
84+ ldx #>_MapPicture-1
85+ jsr _InitTransitionData
86+
87+ jsr StartPictureFromTopAndBottom
88+loop_show_map
89+ jsr PictureFromTopAndBottomFrame
90+ jsr DelayBetweenFrames
91+ bne end_attract_mode
92+
93+ lda _TransitionDone
94+ beq loop_show_map
95+
96+ ; Wait a bit
97+ jsr DelayBetweenPictures
98+ bne end_attract_mode
99+
100+ ; Show credits's scroll picture
101+ lda #<_CreditsPicture-1
102+ ldx #>_CreditsPicture-1
103+ jsr _InitTransitionData
104+
105+ jsr StartPictureVenicianStore
106+loop_show_credits
107+ jsr PictureVenicianStoreFrame
108+ jsr DelayBetweenFrames
109+ bne end_attract_mode
110+
111+ lda _TransitionDone
112+ beq loop_show_credits
113+
114+ ; Wait a bit
115+ jsr DelayBetweenPictures
116+ bne end_attract_mode
117+
118+ jmp loop_attract_mode
119+
120+end_attract_mode
56121 jsr SwitchToText
57122 jsr EndMusic
58123 rts
@@ -59,10 +124,188 @@
59124 .)
60125
61126
127+PrintMessages
128+.(
129+ .(
130+ ; Patch the message to indicate the proper status for the sound
131+ ldy FlagPlayMusic
132+ ldx #0
133+loop
134+ lda MessageOFF,y
135+ sta MessageSoundOnOff,x
136+ iny
137+ inx
138+ cpx #MessageON-MessageOFF
139+ bne loop
140+ .)
141+
142+ .(
143+ ; Patch the message to indicate the proper status for the version to play
144+ ldy FlagPlayImproved
145+ ldx #0
146+loop
147+ lda MessageOriginal,y
148+ sta MessageVersionImprovedOriginal,x
149+ iny
150+ inx
151+ cpx #MessageImproved-MessageOriginal
152+ bne loop
153+ .)
154+
155+ .(
156+ ; Display the options text
157+ ldx #MessageOptionsEnd-MessageOptions
158+loop
159+ lda MessageOptions-1,x
160+ sta $bb80+40*26+0-1,x
161+ dex
162+ bne loop
163+ .)
164+
165+ .(
166+ ; Display the blinking "press space to play"
167+ ldx #MessagePressEnd-MessagePressPlay
168+loop
169+ lda MessagePressPlay-1,x
170+ sta $bb80+40*27+8-1,x
171+ dex
172+ bne loop
173+ .)
174+ rts
175+.)
176+
177+MessageOptions
178+ .byt 3,"[S] Sound"
179+MessageSoundOnOff
180+ .byt " ON [V] Play"
181+MessageVersionImprovedOriginal
182+ .byt " Improved Version"
183+MessageOptionsEnd
184+
185+MessageOFF .byt 1,"OFF",3
186+MessageON .byt 2,"ON ",3
187+
188+MessageOriginal .byt 1,"Original",3
189+MessageImproved .byt 2,"Improved",3
190+
191+MessagePressPlay
192+ .byt 12,4,"Press [SPACE] to play" ; Blue blinking text
193+MessagePressEnd
194+
195+
196+CheckKeyboard
197+.(
198+ lda BASIC_KEY ; Latest key from keyboard, bit 7 set if valid
199+ bmi key_pressed
200+
201+continue
202+ jsr PrintMessages
203+
204+ lda #0
205+ sta BASIC_KEY
206+ rts
207+
208+key_pressed ;jmp quit
209+ cmp #" "+128 ; "SPACE" to quit
210+ beq quit
211+
212+ cmp #"S"+128 ; "S" to toggle sound off and on
213+ bne skip_sound_toggle
214+ lda FlagPlayMusic
215+ eor #MessageON-MessageOFF ; Lenght of the ON/OFF message
216+ sta FlagPlayMusic
217+ bne continue
218+ jsr StopSound ; Make sure to stop the YM to avoid sounnnnnnnnnnnnnnnnnnnnnddddddddd
219+ jmp continue
220+skip_sound_toggle
221+
222+ cmp #"V"+128 ; "V" to toggle between original and improved version
223+ bne skip_version_toggle
224+ lda FlagPlayImproved
225+ eor #MessageImproved-MessageOriginal ; Lenght of the Improved/Original message
226+ sta FlagPlayImproved
227+ jmp continue
228+skip_version_toggle
229+
230+ ; Entual other options
231+ jmp continue
232+
233+quit
234+ lda #1
235+ sta should_quit
236+ rts
237+.)
238+
239+
240+DelayBetweenFrames
241+.(
242+ jsr _VSync
243+ jsr _VSync
244+ jmp CheckKeyboard
245+.)
246+
247+DelayBetweenPictures
248+.(
249+ ldx #50*3 ; We wait three seconds
250+ stx counter
251+loop
252+ jsr DelayBetweenFrames
253+ bne quit
254+ dec counter
255+ bne loop
256+ lda #0
257+quit
258+ rts
259+.)
260+
261+
262+CopyTextFontToHires
263+.(
264+ ; ROM Font is stored from $FC78 to $FF77 = 768 bytes = 3*256
265+ ; We recopy whatever is in the original RAM version of from (from $B400 to $B7FF) to the ROM area.
266+ ; The first 32 characters are skipped because they are not actually displayable.
267+ ldx #0
268+loop_copy_font
269+ lda $B400+8*32+256*0,x
270+ sta $9800+8*32+256*0,x
271+ lda $B400+8*32+256*1,x
272+ sta $9800+8*32+256*1,x
273+ lda $B400+8*32+256*2,x
274+ sta $9800+8*32+256*2,x
275+ dex
276+ bne loop_copy_font
277+ rts
278+.)
279+
280+CopyHiresFontToText
281+.(
282+ ; ROM Font is stored from $FC78 to $FF77 = 768 bytes = 3*256
283+ ; We recopy whatever is in the original RAM version of from (from $B400 to $B7FF) to the ROM area.
284+ ; The first 32 characters are skipped because they are not actually displayable.
285+ ldx #0
286+loop_copy_font
287+ lda $9800+8*32+256*0,x
288+ sta $B400+8*32+256*0,x
289+ lda $9800+8*32+256*1,x
290+ sta $B400+8*32+256*1,x
291+ lda $9800+8*32+256*2,x
292+ sta $B400+8*32+256*2,x
293+ dex
294+ bne loop_copy_font
295+ rts
296+.)
297+
298+
62299 ClearVideo
63- ;jmp SwitchToHires
64300 .(
65301 ; Clean the entire screen area from $A000 to $BFFF with zeroes (BLACK INK attribute)
302+ sei
303+
304+ lda FlagPlayImproved
305+ pha
306+ lda FlagPlayMusic ; Temporarily save the flags at the end of the memory because they are going to be wiped out
307+ pha
308+
66309 lda #<$a000
67310 sta tmp0+0
68311 lda #>$a000
@@ -80,6 +323,13 @@
80323 inc tmp0+1
81324 dex
82325 bne next_page
326+
327+ pla
328+ sta FlagPlayMusic
329+ pla
330+ sta FlagPlayImproved
331+
332+ cli
83333 rts
84334 .)
85335
@@ -86,6 +336,9 @@
86336
87337 SwitchToHires
88338 .(
339+ ; Move the font so we can still display stuff
340+ jsr CopyTextFontToHires
341+
89342 ; Clean the entire screen area from $A000 to $BFFF with zeroes (BLACK INK attribute)
90343 jsr ClearVideo
91344
@@ -105,7 +358,13 @@
105358 lda #26
106359 sta $bfdf
107360
108- jmp _VSync
361+ jsr _VSync
362+ jsr _VSync
363+ jsr _VSync
364+ jsr _VSync
365+
366+ ; Move back the font
367+ jmp CopyHiresFontToText
109368 .)
110369
111370
@@ -136,12 +395,14 @@
136395 rts
137396 .)
138397
139-
140398 PictureUnrollFrame
141399 .(
142400 ldy pos_y
143401 cpy #216
144402 bne do_frame
403+
404+ lda #1
405+ sta _TransitionDone
145406 rts
146407
147408 do_frame
@@ -186,14 +447,163 @@
186447 .)
187448
188449
450+StartPictureVenicianStore
451+.(
452+ ldy #0
453+ sty pos_y
454+ rts
455+.)
189456
190-_InitTransitionData
457+; A simple copy with multiple simultaneous displayed bands
458+; tmp0 -> tmp1
459+; tmp2 -> tmp3
460+; tmp4 -> tmp5
461+; tmp6 -> tmp7
462+PictureVenicianStoreFrame
191463 .(
192- lda #<_TitlePicture-1
464+ ldx pos_y
465+ cpx #50
466+ bne do_frame
467+
468+ lda #1
469+ sta _TransitionDone
470+ rts
471+
472+do_frame
473+ lda _PictureLoadBufferAddrLow,x
193474 sta tmp0+0
194- lda #>_TitlePicture-1
475+ lda _PictureLoadBufferAddrHigh,x
195476 sta tmp0+1
196477
478+ lda _ScreenAddrLow,x
479+ sta tmp1+0
480+ lda _ScreenAddrHigh,x
481+ sta tmp1+1
482+
483+
484+ lda _PictureLoadBufferAddrLow+50,x
485+ sta tmp2+0
486+ lda _PictureLoadBufferAddrHigh+50,x
487+ sta tmp2+1
488+
489+ lda _ScreenAddrLow+50,x
490+ sta tmp3+0
491+ lda _ScreenAddrHigh+50,x
492+ sta tmp3+1
493+
494+ lda _PictureLoadBufferAddrLow+100,x
495+ sta tmp4+0
496+ lda _PictureLoadBufferAddrHigh+100,x
497+ sta tmp4+1
498+
499+ lda _ScreenAddrLow+100,x
500+ sta tmp5+0
501+ lda _ScreenAddrHigh+100,x
502+ sta tmp5+1
503+
504+
505+ lda _PictureLoadBufferAddrLow+150,x
506+ sta tmp6+0
507+ lda _PictureLoadBufferAddrHigh+150,x
508+ sta tmp6+1
509+
510+ lda _ScreenAddrLow+150,x
511+ sta tmp7+0
512+ lda _ScreenAddrHigh+150,x
513+ sta tmp7+1
514+
515+ ; Copy from right to left to limit the attribute corruption effects
516+ ldy #40
517+loop
518+ lda (tmp0),y
519+ sta (tmp1),y
520+
521+ lda (tmp2),y
522+ sta (tmp3),y
523+
524+ lda (tmp4),y
525+ sta (tmp5),y
526+
527+ lda (tmp6),y
528+ sta (tmp7),y
529+
530+ dey
531+ bne loop
532+
533+ inc pos_y
534+ rts
535+.)
536+
537+
538+
539+StartPictureFromTopAndBottom
540+.(
541+ ldy #0
542+ sty pos_y
543+ ldy #199
544+ sty pos_y2
545+ rts
546+.)
547+
548+; A simple copy from the top and bottom at the same time
549+; tmp0 -> tmp1
550+; tmp2 -> tmp3
551+PictureFromTopAndBottomFrame
552+.(
553+ ldx pos_y
554+ cpx #100
555+ bne do_frame
556+
557+ lda #1
558+ sta _TransitionDone
559+ rts
560+
561+do_frame
562+ ldy pos_y2
563+
564+ lda _PictureLoadBufferAddrLow,x
565+ sta tmp0+0
566+ lda _PictureLoadBufferAddrHigh,x
567+ sta tmp0+1
568+
569+ lda _ScreenAddrLow,x
570+ sta tmp1+0
571+ lda _ScreenAddrHigh,x
572+ sta tmp1+1
573+
574+ lda _PictureLoadBufferAddrLow,y
575+ sta tmp2+0
576+ lda _PictureLoadBufferAddrHigh,y
577+ sta tmp2+1
578+
579+ lda _ScreenAddrLow,y
580+ sta tmp3+0
581+ lda _ScreenAddrHigh,y
582+ sta tmp3+1
583+
584+ ; Copy from right to left to limit the attribute corruption effects
585+ ldy #40
586+loop
587+ lda (tmp0),y
588+ sta (tmp1),y
589+ lda (tmp2),y
590+ sta (tmp3),y
591+ dey
592+ bne loop
593+
594+ inc pos_y
595+ dec pos_y2
596+ rts
597+.)
598+
599+
600+
601+; Call with A:X containing the picture location
602+_InitTransitionData
603+.(
604+ sta tmp0+0
605+ stx tmp0+1
606+
197607 lda #<$a000-1
198608 sta tmp1+0
199609 lda #>$a000-1
@@ -243,6 +653,8 @@
243653 bne loop
244654 .)
245655
656+ lda #0
657+ sta _TransitionDone
246658 rts
247659 .)
248660
@@ -358,6 +770,14 @@
358770 sta $246
359771
360772 ; Stop the sound
773+ jsr StopSound
774+
775+ pla
776+ plp
777+ rts
778+
779+StopSound
780+.(
361781 lda #8
362782 ldx #0
363783 jsr WriteRegister
@@ -369,12 +789,10 @@
369789 lda #10
370790 ldx #0
371791 jsr WriteRegister
792+ rts
793+.)
372794
373- pla
374- plp
375- rts
376795
377-
378796 _50hzFlipFlop .byt 0
379797 _VblCounter .byt 0
380798
@@ -393,9 +811,10 @@
393811 sta _50hzFlipFlop
394812 beq skipFrame
395813
396-#ifdef PLAY_MUSIC
814+ lda FlagPlayMusic
815+ beq end_music
397816 jsr _Mym_PlayFrame
398-#endif
817+end_music
399818 inc _VblCounter
400819
401820 skipFrame
@@ -966,6 +1385,13 @@
9661385 ; Wave form
9671386 .byt 8
9681387
1388+_TransitionDone .byt 0
1389+
1390+pos_y .byt 0
1391+pos_y2 .byt 0
1392+counter .byt 0
1393+
1394+
9691395 _MusicData
9701396 #include "build\music.s" ; Generated by ym2mym + bin2txt
9711397 MusicEnd
@@ -973,8 +1399,12 @@
9731399 _TitlePicture
9741400 #include "build\title_picture.s" ; Generated by pictconv
9751401
976- .bss
1402+_CreditsPicture
1403+#include "build\credits_picture.s" ; Generated by pictconv
9771404
1405+_MapPicture
1406+#include "build\map_picture.s" ; Generated by pictconv
1407+
9781408 .dsb 256-(*&255)
9791409
9801410 _PlayerBuffer .dsb 256*14 ; $6800 ; .dsb 256*14 (About 3.5 kilobytes)
@@ -989,4 +1419,8 @@
9891419 _EmptySourceScanLine .dsb 256 ; Only zeroes, can be used for special effects
9901420 _EmptyDestinationScanLine .dsb 256 ; Only zeroes, can be used for special effects
9911421
1422+; Just so log code to check how large this patch data has become
1423+_End
1424+#echo Intro size:
1425+#print (_End - _Main)
9921426
--- users/dbug/UpgradeTime/TheHobbit/osdk_build.bat (revision 1578)
+++ users/dbug/UpgradeTime/TheHobbit/osdk_build.bat (revision 1579)
@@ -13,8 +13,13 @@
1313
1414 :: Convert the graphical and audio data
1515 %OSDKB%\pictconv -u1 -m0 -f6 -o4-TitlePicture data\title.png build\title_picture.s
16+%OSDKB%\pictconv -u1 -m0 -f1 -o4-CreditsPicture data\credits.png build\credits_picture.s
17+%OSDKB%\pictconv -u1 -m0 -f1 -o4-MapPicture data\map.png build\map_picture.s
18+
19+:: Convert the medieval looking character set
1620 %OSDKB%\pictconv -m0 -f0 -o1 data\font_6x8_oncial.png build\font_6x8.tap
1721
22+:: Convert the music for the intro
1823 %OSDK%\bin\ym2mym -h0 -m15872 data\music.ym build\music.mym
1924 %OSDKB%\bin2txt -s1 -f2 build\music.mym build\music.s _Music
2025
--- users/dbug/UpgradeTime/TheHobbit/patch.s (revision 1578)
+++ users/dbug/UpgradeTime/TheHobbit/patch.s (revision 1579)
@@ -11,6 +11,10 @@
1111 ; - 1.3 - 2022-02-24 [Dbug] Replaced the system font by a fancy one ("oncial") to make the game feel a bit more atmospheric
1212 ; - 1.4 - 2022-02-25 [Dbug] Added an intro picture based on the original game manual artwork
1313 ; - 1.5 - 2022-02-26 [Dbug] The intro picture now appears with an unroll effect, and a music play in the background
14+; - 1.6 - 2022-03-12 [Dbug] Added Thror's map as well as a credit picture to the intro, with two new display effects
15+; Added a menu to toggle the sound ON/OFF
16+; Added a menu to allow the player to start the original version of the game
17+; Fixed the brief flash of white corruption appearing when the game starts by clearing the entire video memory area
1418 ;
1519 ; TODO list:
1620 ; - Modify the SAVE and LOAD code to use the floppy disk instead of tape
@@ -24,6 +28,7 @@
2428 ; - The $405-$414 area contains a JMP table on various ROM routines patched to different addresses depending if an Oric 1 or Atmos is detected (See: https://forum.defence-force.org/viewtopic.php?p=26656#p26656)
2529 ; - The saving code is called multiple time for various areas, totally about 3623 bytes (see: https://forum.defence-force.org/viewtopic.php?p=26664#p26664)
2630 ;
31+#include "common.h"
2732
2833 .zero
2934
@@ -36,6 +41,13 @@
3641 *= $924E
3742
3843 StartPatch
44+ ; Check the top of memory flags to see if the user wants to install the improved edition patch
45+ lda FlagPlayImproved
46+ bne install_patch
47+ ; Looks like the user wants to try the original unmodified game!
48+ jmp start_game
49+
50+install_patch
3951 ;pause jmp pause ; Uncomment to stop auto-running
4052 sei ; We need to disable the IRQ at least during the ROM to RAM copy
4153
@@ -148,7 +160,28 @@
148160 bne loop_patch
149161 .)
150162
163+clear_video
164+ .(
165+ ; Clean the entire screen area from $A000 to $BFFF with zeroes (BLACK INK attribute) to avoid the nasty white garbage flash on startup
166+ lda #<$a000
167+ sta tmp0+0
168+ lda #>$a000
169+ sta tmp0+1
151170
171+ lda #0
172+ ldx #32
173+next_page
174+ tay
175+clear_page
176+ sta (tmp0),y
177+ dey
178+ bne clear_page
179+
180+ inc tmp0+1
181+ dex
182+ bne next_page
183+ .)
184+
152185 start_game
153186 cli ; Enable the IRQ again
154187 jmp $91B2 ; What the original did in 04FE
@@ -179,7 +212,7 @@
179212
180213
181214 ; And some final information string, so we can easily find which version people are swapping around
182- .byt "Improved Hobbit v1.5 - Please report any issue to dbug@defence-force.org"
215+ .byt "Improved Hobbit v1.6 - Please report any issue to dbug@defence-force.org"
183216
184217 ; Just so log code to check how large this patch data has become
185218 EndPatch
Show on old repository browser