简体   繁体   English

如何使用easy68k将文本缓慢输出到控制台

[英]How to slowly output text to the console using easy68k

I'm currently creating a simple space-style resource management game in easy68k. 我目前正在用easy68k创建一个简单的空间样式资源管理游戏。

One part of my game consists of a simple loop which signifies the point from which the players fleet leaves home base to when they reach their mission destination. 我的游戏的一部分由一个简单的循环组成,该循环指示玩家的舰队从其离开基地直至到达任务目的地的那一点。 The loop is controlled by the distance to travel and the ships fuel. 该回路由行进距离和船舶燃料控制。 So if the fuel runs out then I will add in a function that will let the player know they didn't make it to their destination and they have lost their ships. 因此,如果燃料用完了,那么我将添加一个函数,该函数将使玩家知道他们没有到达目的地并且他们失去了飞船。

In between all of this happening I have a random number generated from 1-100, depending on the number generated, a certain event may happen eg the player will find some salvage, crewmen, abandoned ships, pirates etc. When one of these events occurs I want to output a message to the console screen to let the player know. 在这一切发生之间,我有一个从1到100生成的随机数,具体取决于生成的数字,可能会发生某个事件,例如,玩家会发现一些打捞,船员,被遗弃的船只,海盗等。当这些事件之一发生时我想在控制台屏幕上输出一条消息,让玩家知道。

My problem is that when the loop is run, if any events occur, they are all output to the screen in less than a second and the player ends up missing out on most of the events. 我的问题是,运行循环时,如果发生任何事件,它们都将在不到一秒钟的时间内输出到屏幕上,并且播放器最终会丢失大多数事件。

I'm wondering, is there a way to delay the output so that the writing appears at a pace that the player can easily follow? 我想知道,是否有一种方法可以延迟输出,以便使文字以玩家可以轻松跟随的速度显示?

Any help would be greatly appreciated. 任何帮助将不胜感激。

If it helps here is my loop, I'm not fully finished implementing all mechanics but the loop itself works fine. 如果这对我的循环有用,那么我还没有完全完成所有机制的实现,但是循环本身可以正常工作。

      *-------------------------------------------------------
      *---------------Update Mission Progress-----------------
      *  Move to mission location, random events will occur
      *------------------------------------------------------- 
update:
bsr     endl            print a CR and LF
bsr     decorate        decorate with dots using a loop

move.w  $4000, D7       move distance value into D7
move.w  $4020, D6       move fuel value into D6

lea     update_msg,A1   Display update message
move.b  #14,D0
trap    #15

update_loop:

move.b  #8,d0           Get time 1/100th seconds since midnight
trap    #15
and.l   #$5FFFFF,D1     prevent overflow in divu
divu    #100,D1         time count / 100
swap    D1              swap upper and lower words of D1 to put remainder in low word
addq.w  #1,D1           d1.w contains number from 1 to 100
move    D1,D2           d2 = d1

bsr     check_events    check to see if any of the events will occur   

sub.b   #fuel_cost, D6  reduce ships fuel by one
CMP     #0, D6          if the ships fuel reaches 0 then go to out of fuel routine
BEQ     out_of_fuel     

sub.b   #1, D7          reduce mission distance by 1               
CMP     #0, D7          when it reaches 0 go to the continue subroutine            
BNE     update_loop     otherwise go back to the top of the loop

BRA     continue_loop 

continue_loop:
*Used to leave the update loop
lea     continue_msg,A1 
move.b  #14,D0
trap    #15

move.b  #5,D0           wait for input so the player can read the event messages
trap    #15

CMP     $94, D1
BNE     continue_loop


move.w  D6, $4020       store the new value for ship fuel

bsr     decorate                           
rts

check_events:    
*Check to make sure the random value is within the specific range for each event
CMP     #95, D2
BGE     check_found_salvage

CMP     #75, D2
BGE     check_hit_mine

CMP     #55, D2
BGE     check_pirate_attack

CMP     #35, D2
BGE     check_found_ship

CMP     #15, D2
BGE     check_found_crew

rts
*Further checks to make sure the random value is within the specific ranges 
check_found_salvage:

CMP     #97, D2                   
BLE     collect_salvage              
rts                                 

check_hit_mine:

CMP     #77, D2                    
BLE     hit_mine              
rts                 

check_pirate_attack:

CMP     #57, D2                    
BLE     initiate_attack              
rts                 

check_found_ship:

CMP     #37, D2
BLE     check_collect_ship
RTS

check_found_crew:

CMP     #17, D2
BLE     collect_crew
rts
*Run each event, outputting a message to the screen if an event occurs  
collect_salvage:

lea     found_salvage_msg,A1   
move.b  #14,D0
trap    #15

rts                                 

hit_mine:   

lea     hit_mine_msg,A1   
move.b  #14,D0
trap    #15

rts

initiate_attack:    

lea     initiate_attack_msg,A1   
move.b  #14,D0
trap    #15

rts

check_collect_ship:    

lea     found_ship_msg ,A1   
move.b  #14,D0
trap    #15

rts

collect_crew:    

lea     found_crew_msg,A1   
move.b  #14,D0
trap    #15

rts
*Not fully implemented out of fuel mechanic yet
out_of_fuel:
rts

According to the Easy68k forums there is a trap to just wait a specified amount of time: 根据Easy68k论坛,有一个陷阱可以等待指定的时间:

move.l   #100,D1     ; delay in 1/100th of seconds
moveq    #23,D0
trap     #15

You could just use this trap to wait for a bit after printing an event? 您可以使用该陷阱在打印事件后稍等吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM