Previous 15994 Revisions Next

r8395 Monday 5th July, 2010 at 22:16:39 UTC by Miodrag Milanović
- Renamed game with name longer then 8 chars, also renamed files with same name and different CRC
- Moved eventlst.c to video/spectrum.c (All now in one file so easier to rewrite)
- Removed usage of eventlst.c in KC (driver is anyway in non working state and this is hacky)
[hash]spectrum.xml
[src/mess]eventlst.c eventlst.h messcore.mak
[src/mess/drivers]spectrum.c
[src/mess/formats]spec_snqk.c
[src/mess/includes]spectrum.h
[src/mess/video]kc.c spectrum.c timex.c

hash/spectrum.xml
r8394r8395
132132         </dataarea>
133133      </part>
134134   </software>
135   <software name="montezuma">
135   <software name="montezum">
136136      <description>Montezuma's Revenge (Prototype)</description>
137137      <year>1984</year>
138138      <publisher>Parker Software</publisher>
r8394r8395
142142         </dataarea>
143143      </part>
144144   </software>         
145   <software name="montezuma1" cloneof="montezuma">
145   <software name="montezuma1" cloneof="montezum">
146146      <description>Montezuma's Revenge (Prototype, Alt)</description>
147147      <year>1984</year>
148148      <publisher>Parker Software</publisher>
149149      <part name="cart" interface="spectrum_cart">
150150         <dataarea name="rom" size="16384">
151            <rom name="montezuma&apos;s revenge.rom" size="16384" crc="5d73082e" sha1="e8f1b6e6b8c8eb6de6a0c6d271351ca7056a39af" offset="000000" />
151            <rom name="montezuma&apos;s revenge (prot).rom" size="16384" crc="5d73082e" sha1="e8f1b6e6b8c8eb6de6a0c6d271351ca7056a39af" offset="000000" />
152152         </dataarea>
153153      </part>
154154   </software>   
src/mess/eventlst.c
r8394r8395
1#include "emu.h"
2#include "eventlst.h"
3
4/* current item */
5static EVENT_LIST_ITEM *pCurrentItem;
6/* number of items in buffer */
7static int NumEvents = 0;
8
9/* size of the buffer - used to prevent buffer overruns */
10static int TotalEvents = 0;
11
12/* the buffer */
13static char *pEventListBuffer = NULL;
14
15/* Cycle count at last frame draw - used for timing offset calculations */
16static int LastFrameStartTime = 0;
17
18static int CyclesPerFrame=0;
19
20/* initialise */
21
22/* if the CPU is the controlling factor, the size of the buffer
23can be setup as:
24
25Number_of_CPU_Cycles_In_A_Frame/Minimum_Number_Of_Cycles_Per_Instruction */
26void EventList_Initialise(running_machine *machine, int NumEntries)
27{
28   pEventListBuffer = auto_alloc_array(machine, char, NumEntries);
29   TotalEvents = NumEntries;
30   CyclesPerFrame = 0;
31   EventList_Reset();
32}
33
34/* reset the change list */
35void    EventList_Reset(void)
36{
37   NumEvents = 0;
38   pCurrentItem = (EVENT_LIST_ITEM *)pEventListBuffer;
39}
40
41
42/* add an event to the buffer */
43void   EventList_AddItem(int ID, int Data, int Time)
44{
45        if (NumEvents < TotalEvents)
46        {
47                /* setup item only if there is space in the buffer */
48                pCurrentItem->Event_ID = ID;
49                pCurrentItem->Event_Data = Data;
50                pCurrentItem->Event_Time = Time;
51
52                pCurrentItem++;
53                NumEvents++;
54        }
55}
56
57/* set the start time for use with EventList_AddItemOffset usually this will
58   be cpu_getcurrentcycles() at the time that the screen is being refreshed */
59void    EventList_SetOffsetStartTime(int StartTime)
60{
61        LastFrameStartTime = StartTime;
62}
63
64/* add an event to the buffer with a time index offset from a specified time */
65void    EventList_AddItemOffset(running_machine *machine, int ID, int Data, int Time)
66{
67
68        if (!CyclesPerFrame)
69                CyclesPerFrame = (int)(cpu_get_clock(machine->firstcpu) / machine->primary_screen->frame_period().attoseconds);   //totalcycles();    //_(int)(cpunum_get_clock(0) / machine->config->frames_per_second);
70
71        if (NumEvents < TotalEvents)
72        {
73                /* setup item only if there is space in the buffer */
74                pCurrentItem->Event_ID = ID;
75                pCurrentItem->Event_Data = Data;
76
77                Time -= LastFrameStartTime;
78                if ((Time < 0) || ((Time == 0) && NumEvents))
79                        Time+= CyclesPerFrame;
80                pCurrentItem->Event_Time = Time;
81
82                pCurrentItem++;
83                NumEvents++;
84        }
85}
86
87/* get number of events */
88int     EventList_NumEvents(void)
89{
90   return NumEvents;
91}
92
93/* get first item in buffer */
94EVENT_LIST_ITEM *EventList_GetFirstItem(void)
95{
96   return (EVENT_LIST_ITEM *)pEventListBuffer;
97}
src/mess/eventlst.h
r8394r8395
1typedef struct EVENT_LIST_ITEM
2{
3   /* driver defined ID for this write */
4   int   Event_ID;
5   /* driver defined data for this write */
6   int   Event_Data;
7   /* time at which this write occured */
8   int Event_Time;
9} EVENT_LIST_ITEM;
10
11void   EventList_Initialise(running_machine *machine, int NumEntries);
12void    EventList_Reset(void);
13void    EventList_AddItem(int ID, int Data,int Time);
14void    EventList_SetOffsetStartTime(int StartTime);
15void    EventList_AddItemOffset(running_machine *machine, int ID, int Data,int Time);
16int     EventList_NumEvents(void);
17EVENT_LIST_ITEM *EventList_GetFirstItem(void);
src/mess/messcore.mak
r8394r8395
7575   $(MESSOBJ)/mess.o      \
7676   $(MESSOBJ)/uimess.o      \
7777   $(MESSOBJ)/utils.o      \
78   $(MESSOBJ)/eventlst.o   \
7978   $(MESSOBJ)/cheatms.o   \
8079
8180$(LIBEMU): $(EMUOBJS)
src/mess/includes/spectrum.h
r8394r8395
127127                int LeftBorderPixels, int ScreenPixels, int RightBorderPixels,
128128                int LeftBorderCycles, int ScreenCycles, int RightBorderCycles,
129129                int HorizontalRetraceCycles, int VRetraceTime, int EventID);
130
131            typedef struct EVENT_LIST_ITEM
132{
133   /* driver defined ID for this write */
134   int   Event_ID;
135   /* driver defined data for this write */
136   int   Event_Data;
137   /* time at which this write occured */
138   int Event_Time;
139} EVENT_LIST_ITEM;
140
141void   EventList_Initialise(running_machine *machine, int NumEntries);
142void    EventList_Reset(void);
143void    EventList_AddItem(int ID, int Data,int Time);
144void    EventList_SetOffsetStartTime(int StartTime);
145void    EventList_AddItemOffset(running_machine *machine, int ID, int Data,int Time);
146int     EventList_NumEvents(void);
147EVENT_LIST_ITEM *EventList_GetFirstItem(void);
130148           
131149/*----------- defined in video/timex.c -----------*/
132150extern VIDEO_EOF( ts2068 );
src/mess/video/spectrum.c
r8394r8395
1515
1616#include "emu.h"
1717#include "includes/spectrum.h"
18#include "eventlst.h"
1918
20
2119/***************************************************************************
2220  Start the video hardware emulation.
2321***************************************************************************/
r8394r8395
531529   EventList_Reset();
532530   EventList_SetOffsetStartTime ( cpu_attotime_to_clocks(machine->firstcpu, attotime_mul(machine->primary_screen->scan_period(), machine->primary_screen->vpos())) );
533531}
532
533/* current item */
534static EVENT_LIST_ITEM *pCurrentItem;
535/* number of items in buffer */
536static int NumEvents = 0;
537
538/* size of the buffer - used to prevent buffer overruns */
539static int TotalEvents = 0;
540
541/* the buffer */
542static char *pEventListBuffer = NULL;
543
544/* Cycle count at last frame draw - used for timing offset calculations */
545static int LastFrameStartTime = 0;
546
547static int CyclesPerFrame=0;
548
549/* initialise */
550
551/* if the CPU is the controlling factor, the size of the buffer
552can be setup as:
553
554Number_of_CPU_Cycles_In_A_Frame/Minimum_Number_Of_Cycles_Per_Instruction */
555void EventList_Initialise(running_machine *machine, int NumEntries)
556{
557   pEventListBuffer = auto_alloc_array(machine, char, NumEntries);
558   TotalEvents = NumEntries;
559   CyclesPerFrame = 0;
560   EventList_Reset();
561}
562
563/* reset the change list */
564void    EventList_Reset(void)
565{
566   NumEvents = 0;
567   pCurrentItem = (EVENT_LIST_ITEM *)pEventListBuffer;
568}
569
570
571/* add an event to the buffer */
572void   EventList_AddItem(int ID, int Data, int Time)
573{
574        if (NumEvents < TotalEvents)
575        {
576                /* setup item only if there is space in the buffer */
577                pCurrentItem->Event_ID = ID;
578                pCurrentItem->Event_Data = Data;
579                pCurrentItem->Event_Time = Time;
580
581                pCurrentItem++;
582                NumEvents++;
583        }
584}
585
586/* set the start time for use with EventList_AddItemOffset usually this will
587   be cpu_getcurrentcycles() at the time that the screen is being refreshed */
588void    EventList_SetOffsetStartTime(int StartTime)
589{
590        LastFrameStartTime = StartTime;
591}
592
593/* add an event to the buffer with a time index offset from a specified time */
594void    EventList_AddItemOffset(running_machine *machine, int ID, int Data, int Time)
595{
596
597        if (!CyclesPerFrame)
598                CyclesPerFrame = (int)(cpu_get_clock(machine->firstcpu) / machine->primary_screen->frame_period().attoseconds);   //totalcycles();    //_(int)(cpunum_get_clock(0) / machine->config->frames_per_second);
599
600        if (NumEvents < TotalEvents)
601        {
602                /* setup item only if there is space in the buffer */
603                pCurrentItem->Event_ID = ID;
604                pCurrentItem->Event_Data = Data;
605
606                Time -= LastFrameStartTime;
607                if ((Time < 0) || ((Time == 0) && NumEvents))
608                        Time+= CyclesPerFrame;
609                pCurrentItem->Event_Time = Time;
610
611                pCurrentItem++;
612                NumEvents++;
613        }
614}
615
616/* get number of events */
617int     EventList_NumEvents(void)
618{
619   return NumEvents;
620}
621
622/* get first item in buffer */
623EVENT_LIST_ITEM *EventList_GetFirstItem(void)
624{
625   return (EVENT_LIST_ITEM *)pEventListBuffer;
626}
src/mess/video/timex.c
r8394r8395
1515
1616#include "emu.h"
1717#include "includes/spectrum.h"
18#include "eventlst.h"
1918#include "devices/messram.h"
2019
2120INLINE void spectrum_plot_pixel(bitmap_t *bitmap, int x, int y, UINT32 color)
src/mess/video/kc.c
r8394r8395
88
99#include "emu.h"
1010#include "includes/kc.h"
11#include "eventlst.h"
1211#include "devices/messram.h"
1312
1413/* KC85/4 and KC85/3 common graphics hardware */
r8394r8395
112111/* set new blink state - record blink state in event list */
113112void kc85_video_set_blink_state(running_machine *machine, int data)
114113{
115   EventList_AddItemOffset(machine, KC85_VIDEO_EVENT_SET_BLINK_STATE, ((data & 0x01)<<7), cpu_attotime_to_clocks(machine->firstcpu, attotime_mul(machine->primary_screen->scan_period(), machine->primary_screen->vpos())));
114//   EventList_AddItemOffset(machine, KC85_VIDEO_EVENT_SET_BLINK_STATE, ((data & 0x01)<<7), cpu_attotime_to_clocks(machine->firstcpu, attotime_mul(machine->primary_screen->scan_period(), machine->primary_screen->vpos())));
116115}
117116
118117
r8394r8395
497496{
498497   int cycles_remaining_in_frame = KC85_CYCLES_PER_FRAME;
499498
500   EVENT_LIST_ITEM *pItem;
501    int NumItems;
499//   EVENT_LIST_ITEM *pItem;
500//    int NumItems;
502501
503502   struct video_update_state video_update;
504   int cycles_offset = 0;
503//   int cycles_offset = 0;
505504
506505   video_update.render_x = 0;
507506   video_update.render_y = 0;
r8394r8395
517516   video_update.vertical.cycles_remaining_in_state = vertical_graphics_state_lines[video_update.vertical.state];
518517   video_update.vertical.cycles_remaining = KC85_CYCLES_PER_FRAME;
519518
520   /* first item in list */
521   pItem = EventList_GetFirstItem();
522   /* number of items remaining */
523   NumItems = EventList_NumEvents();
519//   /* first item in list */
520//   pItem = EventList_GetFirstItem();
521//   /* number of items remaining */
522//   NumItems = EventList_NumEvents();
523//
524//   while (NumItems)
525//   {
526//      int delta_cycles;
527//
528//      /* number of cycles until event will trigger */
529//      delta_cycles = pItem->Event_Time - cycles_offset;
530//
531//      //logerror("cycles between this event and next: %d\n",delta_cycles);
532//      kc85_common_vh_process_lines(&video_update, delta_cycles);
533//
534//      /* update number of cycles remaining in frame */
535//      cycles_remaining_in_frame -= delta_cycles;
536//      /* set new blink state */
537//      kc85_blink_state = pItem->Event_Data;
538//
539//      /* set new cycles into frame */
540//      cycles_offset = pItem->Event_Time;
541//      /* next event */
542//      pItem++;
543//      /* update number of events remaining */
544//      NumItems--;
545//   }
524546
525   while (NumItems)
526   {
527      int delta_cycles;
528547
529      /* number of cycles until event will trigger */
530      delta_cycles = pItem->Event_Time - cycles_offset;
531
532      //logerror("cycles between this event and next: %d\n",delta_cycles);
533      kc85_common_vh_process_lines(&video_update, delta_cycles);
534
535      /* update number of cycles remaining in frame */
536      cycles_remaining_in_frame -= delta_cycles;
537      /* set new blink state */
538      kc85_blink_state = pItem->Event_Data;
539
540      /* set new cycles into frame */
541      cycles_offset = pItem->Event_Time;
542      /* next event */
543      pItem++;
544      /* update number of events remaining */
545      NumItems--;
546   }
547
548
549548   /* process remainder */
550549   kc85_common_vh_process_lines(&video_update, cycles_remaining_in_frame);
551   EventList_Reset();
552   EventList_SetOffsetStartTime ( cpu_attotime_to_clocks(machine->firstcpu, attotime_mul(machine->primary_screen->scan_period(), machine->primary_screen->vpos())) );
550//   EventList_Reset();
551//   EventList_SetOffsetStartTime ( cpu_attotime_to_clocks(machine->firstcpu, attotime_mul(machine->primary_screen->scan_period(), machine->primary_screen->vpos())) );
553552}
554553
555554
r8394r8395
557556/***************************************************************************
558557 KC85/4 video hardware
559558***************************************************************************/
560
561#ifdef UNUSED_FUNCTION
562static void kc85_common_vh_eof_callback(void)
563{
564      //EVENT_LIST_ITEM *pItem;
565      int NumItems;
566
567      /* Empty event buffer */
568      NumItems = EventList_NumEvents();
569
570      /* to do: the entries in this buffer are ignored. OK? */
571      if (NumItems)
572      {
573         //pItem = EventList_GetFirstItem();
574         EventList_Reset();
575         EventList_SetOffsetStartTime ( cpu_attotime_to_clocks(machine->firstcpu, attotime_mul(machine->primary_screen->scan_period(), machine->primary_screen->vpos())) );
576         logerror ("Event log reset in callback fn.\n");
577      }
578}
579#endif
580
581559static void kc85_common_vh_start(running_machine *machine)
582560{
583561   kc85_blink_state = 0;
584   EventList_Initialise(machine, 30000);
562//   EventList_Initialise(machine, 30000);
585563}
586564
587565static unsigned char *kc85_4_display_video_ram;
src/mess/formats/spec_snqk.c
r8394r8395
2828#include "emu.h"
2929#include "cpu/z80/z80.h"
3030#include "includes/spectrum.h"
31#include "eventlst.h"
3231#include "sound/ay8910.h"
3332#include "formats/spec_snqk.h"
3433#include "utils.h"
src/mess/drivers/spectrum.c
r8394r8395
274274#include "sound/speaker.h"
275275#include "sound/wave.h"
276276#include "includes/spectrum.h"
277#include "eventlst.h"
278277#include "devices/snapquik.h"
279278#include "devices/cartslot.h"
280279#include "devices/cassette.h"

Previous 15994 Revisions Next


© 1998-2018 The MESS Team